How programmatically create an element based on UserControl and dock it to the DockPanel?
+2
A:
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);
Dani
2010-04-09 18:11:47
+2
A:
var myControl = new MyUserControl();
DockPanel.SetDock(myControl, Dock.Left);
myDockPanel.Children.Add(myControl);
Lars Truijens
2010-04-09 18:13:11