Nasıl yapılır: Yerleştirme Değerini Alma veya Ayarlama
Aşağıdaki örnekte, bir nesne için bir Dock değerin nasıl atan olduğu gösterir. Örnek, ve GetDockSetDock yöntemlerini DockPanel kullanır.
Örnek
Örnek, öğesinin bir örneğini oluşturur ve yöntemini TextBlocktxt1 kullanarak değerini DockTopSetDockDockPanel atar. Ardından yöntemini kullanarak Dock öğesinin öğesine TextTextBlock özelliğinin değerini GetDock ekler. Son olarak, örnek öğesini TextBlock üst öğesine DockPaneldp1 ekler.
// Create the Panel DockPanel
dp1 = new DockPanel();
// Create a Text Control and then set its Dock property
txt1 = new TextBlock();
DockPanel.SetDock(txt1, System.Windows.Controls.Dock.Top);
txt1.Text = "The Dock Property is set to " + DockPanel.GetDock(txt1);
dp1.Children.Add(txt1);
mainWindow.Content = dp1;
mainWindow.Show();
' Create the Panel DockPanel
dp1 = New DockPanel()
' Create a Text Control and then set its Dock property
txt1 = New TextBlock()
DockPanel.SetDock(txt1, Dock.Top)
txt1.Text = "The Dock Property is set to " & DockPanel.GetDock(txt1).ToString()
dp1.Children.Add(txt1)
_mainWindow.Content = dp1
_mainWindow.Show()