#324 – Setting a Margin with Different Sizes on Each Edge

You can set the Margin property on a control so that it has some extra room around its edges, within its container.

In XAML, if you specify a single value for Margin, that value will be used as the margin (in WPF Units) along each edge of the control.

        <Label Content="Hello there.." Margin="3"/>
        <Button Content="Click Me" Margin="5"/>

You can also specify four different values for the Margin property, listing the margin along each edge of the control in the order: Left, Top, Right, Bottom.

        <Label Content="Hello there.." Background="Goldenrod" Margin="5,10,2,20"/>
        <Button Content="Click Me"/>


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: