'How can i get the ActualWidth of Grid.Column, after changing its width using *?

In my c# wpf code i used to change programmaticaly the width of a grid column, like this :

 mycolumn.Width = new GridLength(1, GridUnitType.Star);

But later in code, when i try to get the "ActualWidth", at first time, the value of ActualWidth (that is in pixel) it's always 0. The value is updated later by the parent window, for some reason i don't know.

double myWidthInPixels = myColumn.ActualWidth;

myWidthInPixels is set to 0, for the first time i ask it.

How to solve?



Solution 1:[1]

The solution for me was this :

double myWidthInPixels = Convert.ToDouble(myColumn.GetValue(WidthProperty));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Filippo