I want to clone a WPF Control (XamGrid)
XamGrid
I know these ways:
Clone Problem: Control is not Cloneable
can be a solution?
public class DataManagerControlClonableXamGrid : XamGrid, ICloneable
{
public object Clone()
return MemberwiseClone();
}
the purpose is to get a new class instance with a new pointer, as the original xamgrid filtered and sorted data, thanks for your response.
Hello,
Thank you for your post. I have been looking into it and I can suggest you see these two links:
http://stackoverflow.com/questions/32541/how-can-you-clone-a-wpf-object
and
http://stackoverflow.com/questions/2572066/how-to-clone-control-in-wpf
Hope this helps you.
I tried, but it does not work, the object is not serializable:
public T DeepClone<T>(T from)
using (MemoryStream s = new MemoryStream())
BinaryFormatter f = new BinaryFormatter();
f.Serialize(s, from);
s.Position = 0;
object clone = f.Deserialize(s);
return (T)clone;
Yo ucan try to serialize the object using the approach shown here:
http://stackoverflow.com/questions/723142/binary-serialization-of-silverlight-xaml-object