1

I've got a DataGrid in wpf with different columns. I want to change the property "Visibility" of one explicit column via datatrigger, but a cant access the "Style" property.

How can i collapse or hide the hole column?

<DataGrid.Columns>
    <DataGridCheckBoxColumn Binding="{Binding IsChanged, Mode=OneWay}"
                            Header="Changed" 
                            CanUserSort="False">
    </DataGridCheckBoxColumn>

    <!--more columns-->
</DataGrid.Columns>
Charles
  • 50,943
  • 13
  • 104
  • 142
Bddha
  • 11
  • 3
  • Finally I found my solution here: [Bind datagrid column visibility MVVM][1] [1]: http://stackoverflow.com/questions/7711275/bind-datagrid-column-visibility-mvvm – Bddha Feb 07 '13 at 09:50

1 Answers1

1

DataGridRow and DataGridCell have Styles, DataGridColumn doesn't. I'm guessing this is because rows and cells are the only things being displayed in the UI. Columns are only used by DataGrid internally to keep track of its rows and cells and their content.

Conveniently, columns do have a Visibility property though, which you can bind on each specific column:

<DataGridCheckBoxColumn Visibility="{Binding ...}"
                        ...
Sphinxxx
  • 12,484
  • 4
  • 54
  • 84