1

Basically I have some CheckBox controls I want to use to show or hide certain GridViewColumns at runtime. But I failed to find a sort of IsVisible property that I can set to false. Or even a Visibility property that exist only on GridViewColumnHeader.

Any ideas on how to do this?

Joan Venge
  • 315,713
  • 212
  • 479
  • 689

1 Answers1

6

Set the GridViewColumn Width property to 0. This will achieve the same effect as hiding it. This can be achieved with DataBinding and a Converter.

Dave White
  • 3,451
  • 1
  • 20
  • 25
  • Thanks, I did it but the cells aren't hidden after doing this. I want the whole column to be gone as if I resized the column to nothing by hand at runtime. – Joan Venge Apr 06 '11 at 23:58
  • This works in the designer. Just set the width of a column to 0 and you'll see it disappear. If it isn't working, then there is an issue in your implementation. – Dave White Apr 07 '11 at 00:18
  • Thanks it works, I got tripped by a WPF gimmick I asked here: http://stackoverflow.com/questions/5574613/why-are-there-separate-events-for-the-checked-and-unchecked-state-for-a-wpf-check – Joan Venge Apr 07 '11 at 00:43