how to get actual height of Grid Row before rendering

.net, c#, wpf

Solution

You need to do a full layout update, that is you need to call Measure, Arrange and UpdateLayout:

    //Make the framework (re)calculate the size of the element
    _Element.Measure(new Size(Double.MaxValue, Double.MaxValue));
    Size visualSize = _Element.DesiredSize;
    _Element.Arrange(new Rect(new Point(0, 0), visualSize));
    _Element.UpdateLayout();

_Element being a FrameworkElement (Grid is one).

Problem

In my project there are many nested Grids. And mostly rows and columns width is defined as "*" in XAML. I am trying to expand a particular row(lets say Row1) by seting other row's height to 0, and i am using the .ActualHeight property to get the width of Row1 then its not giving me actual height. As per I know that is happening because height and width of Grid rows and columns are set on rendering time. I searched on net and somebody suggested to use UpdateLayout() method ..but that is also not working for me. I can not post code snippet because it is very long code. my project in c#.net wpf.

Original source