I make this column for ListView with TextBox'ом inside and try to bind the Width TextBox'a property to the field of the same name GridViewColumn'a .
<GridViewColumn Width="100"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBox Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GridViewColumn}, Path=Width}" Text="SomeText"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> As a result, no binding occurs. The following message is displayed in Output:
System.Windows.Data Error: 4; Find not Finding Resistance, AncestorType = 'System.Windows.Controls.GridViewColumn', AncestorLevel = '1' '. BindingExpression: Path = Width; DataItem = null; target element is 'TextBox' (Name = ''); target property is 'Width' (type 'Double')
If you specify a name for the GridViewColumn , and bind via ElementName , then everything works. Why does the first option fail?