How programmatically dock new element to DockPanel
-
25-09-2019 - |
Question
How programmatically create an element based on UserControl and dock it to the DockPanel?
OTHER TIPS
Button TopRect = new Button();
TopRect.Background = new SolidColorBrush(Colors.LightGreen);
TopRect.Height = 50;
TopRect.Content = "Top";
// Dock button to top
DockPanel.SetDock(TopRect, Dock.Top);
// Add docked button to DockPanel
dcPanel.Children.Add(TopRect);
var uc = new UserControl1();
uc.SetValue(DockPanel.DockProperty, Dock.Left);
myDockPanel.Children.Add(uc);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow