#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

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 comment