Apr 24

admin

WPF Margin

wpf

The margin property in WPF allows you set spacing between elements in a window. You can assign the margins for the Top, Right, Bottom and Left.

Every control that derives from FrameworkElement has this property.

A simple mark up XAML code with margins is:


    
        

    

It'll render something like this:

Margin in code

The margin property is of type Thickness so you should be able to set margins in code using the following snippet:

buttonTest.Margin = new Thickness(0, 120, 9, 213);

No Comments

Add Comment