#1,194 – DesiredSize of Child Elements Includes Margins

After the measure phase, during which a custom element calls the Measure method on each of its child elements, each child element will set its DesiredSize property to indicate how much space it wants.

The DesiredSize of a child element accounts for any margins that have been set on that child.  Assume that we have the following XAML (MyElement is a custom element with a single child).


        <loc:MyElement x:Name="Left">
                <Label Content="Doowahditty"/>

        <loc:MyElement Grid.Column="1" x:Name="Right">
                <Label Content="Doowahditty" Margin="10"/>

We can see that the child element uses a margin.

We can look at the value of the DesiredSize property after Measure has been called on the child element.  We can see that in the second case, the desired size is larger, indicating that the child wants to add a margin.





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

One Response to #1,194 – DesiredSize of Child Elements Includes Margins

  1. Pingback: Dew Drop – November 4, 2014 (#1891) | 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: