I have a static canvas. I have added a shape runtime. Then I try to add a contentcontrol which will hold the shape. But as the the shape is already added to the canvas, it gives a logical child error. Can anyone help me how to get this done keeping the logic of adding the contentcontrol later dynamically?
XAML: Inside window tag keep a blank canvas with name="cnv"
C#:
Ellipse ee = new Ellipse();
ee.Width = 100;
ee.Height= 50;
ee.Fill= Brushes.Red;
ee.Name = "el";
hidden.Children.Add(ee);
ContentControl cc = new ContentControl();
cc.BorderBrush = Brushes.Black;
cc.Content = ee;
cnv.Children.Add(ee);