akshaykumar6
akshaykumar6

Reputation: 2257

Setting Margin from C# code

I want to set the margins of different controls using C# code-behind (I know how to do it in XAML markup).

I need it for controls like rectangle or buttons.

Upvotes: 4

Views: 4991

Answers (1)

ZombieSheep
ZombieSheep

Reputation: 29963

myControl.Margin = new Thickness(left, top, right, bottom);

or

myControl.Margin = new Thickness(allSideMarginSize);

should do it.

Upvotes: 10

Related Questions