Reputation: 2257
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
Reputation: 29963
myControl.Margin = new Thickness(left, top, right, bottom);
or
myControl.Margin = new Thickness(allSideMarginSize);
should do it.
Upvotes: 10