Cómo acoplar programáticamente un nuevo elemento a DockPanel


¿Cómo crear programáticamente un elemento basado en UserControl y acoplarlo al DockPanel?

Author: iLemming, 2010-04-09

3 answers

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

Ver También aquí y aquí.

 57
Author: Lars Truijens,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-04-09 18:13:11
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);

Ejemplo

 3
Author: Dani,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-04-09 20:23:09
var uc = new UserControl1();
uc.SetValue(DockPanel.DockProperty, Dock.Left);
myDockPanel.Children.Add(uc);
 2
Author: Walter Fuchs,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-01 14:49:00