How programmatically dock new element to DockPanel

iLemming picture iLemming · Apr 9, 2010 · Viewed 29.8k times · Source

How programmatically create an element based on UserControl and dock it to the DockPanel?

Answer

Lars Truijens picture Lars Truijens · Apr 9, 2010
var myControl = new MyUserControl();
DockPanel.SetDock(myControl, Dock.Left);
myDockPanel.Children.Add(myControl);

Also see here and here.