Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-set-margins-of-elements-and-controls.md
T
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* net-current-v30plus-md.md

* net-current-v40plus-md.md

* tla2sharptla-ui-md.md

* tla2sharptla-uiautomation-md.md

* tla2sharptla-winclient-md.md

* tla2sharptla-xaml-md.md

* tlasharptla-ui-md.md

* tlasharptla-uiautomation-md.md

* tlasharptla-winclient-md.md

* tlasharptla-xaml-md.md

* fix warnings
2022-03-16 12:14:11 -04:00

1.3 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Set Margins of Elements and Controls 03/30/2017
csharp
vb
setting [WPF], Margin property
properties [WPF], Margin property
Margin property [WPF], setting
70ebee01-6f87-4352-8dd4-402c65eaaed6

How to: Set Margins of Elements and Controls

This example describes how to set the xref:System.Windows.FrameworkElement.Margin%2A property, by changing any existing property value for the margin in code-behind. The xref:System.Windows.FrameworkElement.Margin%2A property is a property of the xref:System.Windows.FrameworkElement base element, and is thus inherited by a variety of controls and other elements.

This example is written in XAML refers to. The code-behind is shown in both a C# and a Microsoft Visual Basic version.

Example

[!code-xamlFEMarginProgrammatic#XAML]

[!code-csharpFEMarginProgrammatic#Handler] [!code-vbFEMarginProgrammatic#Handler]