I wish to copy a binding, this is so i can set a different source property on it without affecting the original binding. Is this just a case of setting all of the properties
I just started using this. It's not the most efficient but is fast enough for me so far. It's simple and in theory shouldn't miss any properties.
using System.IO;
using System.Windows.Data;
using System.Windows.Markup;
using System.Xml;
static Binding CloneBinding(Binding binding)
{
var xaml = XamlWriter.Save(binding);
var stringReader = new StringReader(xaml);
var xmlReader = XmlReader.Create(stringReader);
return (Binding)XamlReader.Load(xmlReader);
}
Inspired by another question's answer.