0

How can I add a dataTable column that will be hidden in the dataGrid that is binded to that table?

My dataGrid:

<DataGrid Name="typesGrid" RowStyle="{StaticResource RowStyleWithAlternation}" CellStyle="{StaticResource CenterCellStyle}" ColumnHeaderStyle="{StaticResource HeaderStyle}" CanUserAddRows="False" IsReadOnly="{Binding IsTypeReadOnly}" ItemsSource="{Binding TypesTable}">

    </DataGrid>
Yogevnn
  • 1,430
  • 2
  • 18
  • 37

1 Answers1

1

If you know your columns at design time, set AutoGeneratedColumns to False and populate DataGrid.Columns with desired columns, setting Visibility to Collapsed for the column you want to hide. If your columns are dynamic, I suggest looking at this question.

Community
  • 1
  • 1
amnezjak
  • 2,011
  • 1
  • 14
  • 18
  • @Yogevnn Then follow the link I provided at the end. You may create collection of columns manually and then "inject" it into your DataGrid. – amnezjak May 06 '14 at 14:50
  • This is what i'm doing but I want one of the columns to be hidden – Yogevnn May 06 '14 at 14:55
  • do you have any ideas? – Yogevnn May 06 '14 at 16:08
  • Sorry, I don't follow. If you populate columns with your custom collection, then just remove hidden column from that collection or set its Visibility to Collapsed/Hidden. – amnezjak May 06 '14 at 16:21