I have tried this approach first but getting error "Element is already the child of another element"
var objClone = new MyImageControl();
objClone = this;
((Canvas)this.Parent).Children.Add(objClone);
Then I checked this and this, but XamlWriter and XamlReader is not available in WinRT. I have tried to use MemberwiseClone() but it throws exception, "COM object that has been separated from its underlying RCW cannot be used. System.Runtime.InteropServices.InvalidComObjectException
". So can anyone tell me how can I clone the existing UserControl in my canvas to itself ?
You can try serializers other than XamlWriter and XamlReader to achieve the same effect described by your links. For example, use ServiceStack.Text to JSON serialize your object to a string, then get a new object from that string and add it to the parent.
I have written a
UIElement
extension that copies the properties and children of an element -- note that it does not set up an events for the clone.Feel free to use this code if you find it useful.