Reputation: 21855
I'm aware of DataGridColumns
not being on the logical nor visual tree of a grid. I'm using the proxy as shown here.
I need to bind the width of some of the columns. I usually use bindings like this one:
Width="{Binding ActualWidth, ElementName=LastOperationColumn}
However, it is not working. Any idea on how to do this?
Upvotes: 2
Views: 1474
Reputation: 184506
You cannot use ElementName
in a DataGrid column because they are not objects in the visual or logical tree, they have no namescope which is needed for those bindings. You can however use Source
and x:Reference
:
{Binding ActualWidth, Source={x:Reference LastOperationColumn}}
Of course this won't change that the binding is destroyed if this column is resized manually.
Upvotes: 2
Reputation: 8242
I just looked at some code where I'm setting MaxWidth and I think it should be the same. Here's the syntax I used.
<DataGridTextColumn...
MaxWidth="{Binding Source={x:Static Properties:Settings.Default},
Mode=OneWay,
Path=DescriptionMaxWidth}">
Upvotes: 1
Reputation: 166
Try this: Width="{Binding Path=ActualWidth,ElementName=LastOperationColumn}"
Upvotes: 0