Search code examples
wpfuser-controlsdockpanel

How programmatically dock new element to DockPanel


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


Solution

  • var myControl = new MyUserControl();
    DockPanel.SetDock(myControl, Dock.Left);
    myDockPanel.Children.Add(myControl);
    

    Also see here and here.