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}">
XAML ValuesMargin="20,50" will be interpreted to mean a Thickness with Left and Right set to 20, and Top and Bottom set to 50. The default unit for a Thickness measure is device-independent unit (1/96th inch). You can also specify other units by appending the unit type strings cm , in , or pt to any measure.
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.
The Padding property represents the distance between an element and its child elements, and is used to separate the control from its own content. Padding values can be specified on layout classes.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With