2010-04-09 13 views

risposta

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

vedere anche here e here.

+0

Qualche idea sul motivo per cui l'app non risponde dopo aver aggiunto un controllo us su un dockpanel? – IAbstract

+1

@IAbstract, no non dovrebbe accadere. –

+1

In realtà ho capito - URI errato. :(Sembra che questo possa essere gestito con più grazia. Appena chiedi una proprietà dell'immagine, si blocca. – IAbstract

3
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); 

Example

1
var uc = new UserControl1(); 
uc.SetValue(DockPanel.DockProperty, Dock.Left); 
myDockPanel.Children.Add(uc); 
Problemi correlati