As the columns of a data grid aren\'t in the visual tree of datagrid I\'m m using this approach of Binding Proxy to bind Visibility of a DataGridTextColumn
.
The type of the Width
property of a DataGridColumn
is DataGridLength
and not double
.
Change type of your source property:
public DataGridLength Width
{
get { return m_width; }
set { m_width = value; OnPropertyChanged("Width"); }
}
DataGridLength m_width;
And the Mode
of the Binding
:
<DataGridTextColumn Header="ProductId1" Binding="{Binding Path=Result[1]}"
Visibility="{Binding Data.Columns[0].Visible, Source={StaticResource proxy}}"
Width="{Binding Data.Columns[0].Width, Source={StaticResource proxy}, Mode=TwoWay}" />