I have a text string in a TextBox which is in row 0, column 0 of a Grid which is in a DockPanel which is on a Page which is in a NavigationWindow. I am trying to size the width of Column 0 based on the ActualWidth of the string. I am missing something, possibly
that the TextBox is not getting resized to fit the length of the string. (I couldn't find an autoresize property for TextBox.) My approach so far is to resize the ColumnDefinition when the TextBox is Loaded.
Inside my Grid subclass, I have this:
myTextBox.Loaded += (s, e) => this.ColumnDefinitions.Width = new GridLength(myTextBox.ActualWidth, GridUnitType.Pixel);
However, the column width remains the same as when it is created. A breakpoint shows the above line being executed with the ActualWidth being the (too large) value it has when constructed, not what I hope it is when loaded (smaller from a correct measurement).
View Complete Post