Binding to ColumnDefinition.ActualWidth returns 0

actualwidth, binding, grid, wpf, xaml

Solution

No, you didn't. ColumnDefinition does have an `ActualWidth` property, actually. But it's neither `DependencyProperty` nor there `INotifyPropertyChanged` implementation. So nobody let your target know when `ActualWidth` is updated.

Workaround? For what? You can always use `ElementName` binding to the parent `FrameworkElement`, who has exactly that `ActualWidth` that you wanted. Sorry for complex phrase :). Couldn't make it simpler.

Hope this helps.

Problem

Paste this into Cider. ``` <Grid x:Name="Grid"> <Grid.ColumnDefinitions> <ColumnDefinition x:Name="ColumnDefinition"/> </Grid.ColumnDefinitions> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock Text="{Binding ActualWidth, ElementName=Grid}"/> <TextBlock Text="{Binding ActualWidth, ElementName=ColumnDefinition}"/> </StackPanel> </Grid> ``` Now, run it. The second `TextBlock` shows 0, but shouldn't, right? Workaround?

Original source