Columns Visibility based on a checkbox

Nov 3, 2008 at 4:26 AM
I want to hide certain columns based on some checkbox checked/unchecked.
<dg:DataGridTextColumn Header="Order" Visibility ="{Binding ElementName=chkAutoOrders, Path=IsChecked, Converter={StaticResource BoolToVisibility}}" />

unfortunately, it doesn't work.... :(
what am I doing wrong? Please help


Nov 3, 2008 at 12:26 PM
It could possibly be in your converter.  See the sample on this post,, which provides an example of how to bind each column's Visibility property to a combobox where you can show or hide the column.
Nov 3, 2008 at 3:51 PM

You could do same thing in XAML code, in Trigger on container that contains this check box, check the property Is Checked on your checkbox, and if it’s true or false, set Visibility on element to whatever you want to.  

                                                                                                          Thank You. Lena

Nov 5, 2008 at 1:17 AM
Hi Lena,
You suggestion seems quite interesting. I suppose EventTrigger with RoutedEvent="CheckBox.Checked" is required. But how can I set Visibility of some column in the DataGrid from there?