#1,179 – Alignment and Margin Properties for a Custom FrameworkElement

When you create a custom control that derives from FrameworkElement, your control has access to all standard FrameworkElement behavior.  This includes the use of the Margin property, as well as the HorizontalAlignment and VerticalAlignment properties.

Below, we use margin and alignment in positioning a custom framework element within a Grid.

    <Grid ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        
        <loc:MyFrameworkElement HorizontalAlignment="Center"
                                VerticalAlignment="Top"
                                Height="40" Width="100"/>
        <loc:MyFrameworkElement Grid.Row="1" Margin="20,10"/>
    </Grid>

(Showing grid lines for clarity).

1179-001

Advertisement

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

One Response to #1,179 – Alignment and Margin Properties for a Custom FrameworkElement

  1. Pingback: Dew Drop – October 14, 2014 (#1876) | Morning Dew

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 )

Connecting to %s

%d bloggers like this: