Reputation: 26291
How can I create an instance of my UserControl dynamically (in code behind) and display it on the Canvas?
Upvotes: 1
Views: 691
Reputation: 12934
YourUserControlClassName myUC = new YourUserControlClassName();
myCanvas.Children.Add(myUC);
If myCanvas is not dynamic and is in xaml then you need this to get the reference myCanvas
Canvas myCanvas = (Canvas)this.FindName("CanvasNameInXaml");
Upvotes: 2