* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
1.7 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Get or Set a Dock Value | 03/30/2017 |
|
|
fcf4ab8a-c7cd-4835-8d04-de1c999ab4a8 |
How to: Get or Set a Dock Value
The following example shows how to assign a xref:System.Windows.Controls.Dock value for an object. The example uses the xref:System.Windows.Controls.DockPanel.GetDock%2A and xref:System.Windows.Controls.DockPanel.SetDock%2A methods of xref:System.Windows.Controls.DockPanel.
Example
The example creates an instance of the xref:System.Windows.Controls.TextBlock element, txt1, and assigns a xref:System.Windows.Controls.Dock value of Top by using the xref:System.Windows.Controls.DockPanel.SetDock%2A method of xref:System.Windows.Controls.DockPanel. It then appends the value of the xref:System.Windows.Controls.Dock property to the xref:System.Windows.Controls.TextBlock.Text%2A of the xref:System.Windows.Controls.TextBlock element by using the xref:System.Windows.Controls.DockPanel.GetDock%2A method. Finally, the example adds the xref:System.Windows.Controls.TextBlock element to the parent xref:System.Windows.Controls.DockPanel, dp1.
[!code-csharpDockPanelSetDock#1] [!code-vbDockPanelSetDock#1]