The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Windows Presentation Foundation (WPF)!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until March 30, 2020, after which content will be closed to all new and existing posts.

Learn More

How to force the update of actual* measure properties RRS feed

  • Question

  • Hi,

    I have a Grid with borders inside.

    I made this, expecting that, after defininf a width and height for the grid, it will propagate to is children their width and height values, because their are in auto.

    I did the folowing:

                    Grid g = s.Layout; // s contains a Grid with no width and height defined, only borders inside
                    g.Width = 1024;
                    g.Height = 768;              

                    foreach (object obj in g.Children)
                        Border b = obj as Border;

                        if (b != null)

    But, the output of b.ActualWdth is 3... i have tried things like g.InvalidateVisual, but nothing, it continues to be 3.

    How can i force this to update?


    Friday, September 21, 2007 2:16 PM

All replies

  • Make sure the borders contained within the grid do not have any margins set on them (often margins get set by default, especially if you're laying it out in a designer like Blend).


    Also, ensure that the VerticalAlignment and HorizontalAlignment of the borders are all set to "Stretch".

    Friday, September 21, 2007 5:22 PM
  • Hi,


    I don't have margins on the borders.


    Here is an example:






    Width="150" Height="112.5">


    <SolidColorBrush Color="White"/>



    <ColumnDefinition Width="0.8*"/>

    <ColumnDefinition Width="0.2*"/>


    <Border x:Name="_1" Grid.Column="0" BorderBrush="Black" Background="White" BorderThickness="2,2,1,2" />

    <Border x:Name="_2" Grid.Column="1" BorderBrush="Black" Background="White" BorderThickness="1,2,2,2" />





    Monday, September 24, 2007 2:15 PM