Come creare un elemento in modo programmatico basato su UserControl e collegarlo a DockPanel?Come ancorare in modo programmatico un nuovo elemento a DockPanel
29
A
risposta
54
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);
1
var uc = new UserControl1();
uc.SetValue(DockPanel.DockProperty, Dock.Left);
myDockPanel.Children.Add(uc);
Qualche idea sul motivo per cui l'app non risponde dopo aver aggiunto un controllo us su un dockpanel? – IAbstract
@IAbstract, no non dovrebbe accadere. –
In realtà ho capito - URI errato. :(Sembra che questo possa essere gestito con più grazia. Appena chiedi una proprietà dell'immagine, si blocca. – IAbstract