-1

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?

Filippo
  • 56
  • 6
  • check this solution https://stackoverflow.com/questions/7403151/binding-issue-actualwidth-on-dynamic-filled-grid – jæk Feb 22 '22 at 08:51

1 Answers1

-1

The solution for me was this :

double myWidthInPixels = Convert.ToDouble(myColumn.GetValue(WidthProperty));
Filippo
  • 56
  • 6