* 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
2.1 KiB
title, description, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | description | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||
|---|---|---|---|---|---|---|---|---|
| How to: Position the Child Elements of a Grid | Learn how to use the get and set methods that are defined on a Windows Presentation Foundation Grid to position child elements. | 03/30/2017 |
|
|
27b3ba9b-ad32-44e2-bcab-a79d573a463c |
How to: Position the Child Elements of a Grid
This example shows how to use the get and set methods that are defined on xref:System.Windows.Controls.Grid to position child elements.
Example
The following example defines a parent xref:System.Windows.Controls.Grid element (grid1) that has three columns and three rows. A child xref:System.Windows.Shapes.Rectangle element (rect1) is added to the xref:System.Windows.Controls.Grid in column position zero, row position zero. xref:System.Windows.Controls.Button elements represent methods that can be called to reposition the xref:System.Windows.Shapes.Rectangle element within the xref:System.Windows.Controls.Grid. When a user clicks a button, the related method is activated.
[!code-xamlgridGetSetMethods]
The following code-behind example handles the methods that the button xref:System.Windows.Controls.Primitives.ButtonBase.Click events raise. The example writes these method calls to xref:System.Windows.Controls.TextBlock elements that use related get methods to output the new property values as strings.
[!code-csharpgridGetSetMethods#2]
[!code-vbgridGetSetMethods#2]
Here is the finished result!
