0
  1. What is necessary to make a complete separate copy of a Binding object in Silverlight 4.0?
  2. Is it enough just to copy its every single settable property?

UPDATE

As far as I can see the answer to the second question is NO. Because setting properties on a binding triggers it's state which cannot be change once initialized. For example although nothing would stop you from setting the Source and RelativeSource properties, you would get an exception at run-time because once the Source property is set you cannot set RelativeSource anymore. The same thing with the ElementName property that cannot be assigned to NULL even though it already holds NULL by default.

Trident D'Gao
  • 18,973
  • 19
  • 95
  • 159

1 Answers1

0

Are you trying to clone POCO objects in Silverlight? If so you can implement something like this:

public static T Clone<T>(T source)
{

    DataContractSerializer serializer = new DataContractSerializer(typeof(T));
    using (MemoryStream ms = new MemoryStream())
    {
        serializer.WriteObject(ms, source);
        ms.Seek(0, SeekOrigin.Begin);
        return (T)serializer.ReadObject(ms);
    }
} 
Myles J
  • 2,839
  • 3
  • 25
  • 41
  • Is the Binding class from System.Windows.Data a POCO class? – Trident D'Gao Nov 30 '12 at 12:27
  • We use the function above to clone data contract POCO objects returned from our WCF services. See http://stackoverflow.com/questions/250001/poco-definition. – Myles J Nov 30 '12 at 12:53