How to set a top margin only in XAML?

Edward Tanguay picture Edward Tanguay · Aug 22, 2009 · Viewed 67k times · Source

I can set margins individually in code but how do I do it in XAML, e.g. how do I do this:

PSEUDO-CODE:

<StackPanel Margin.Top="{Binding TopMargin}">

Answer

Carlo picture Carlo · Aug 23, 2009

Isn't this what you're looking for?

<StackPanel Margin="0,10,0,0" />

The first value is Left margin, then Top, then Right, and last but not least Bottom.

I'm not sure if you want to bind it to something, but if not, that'll work.