In this article we will see how we can hide or unhide the columns in a DataGrid.
Creating WPF Application Project
Fire up Visual Studio 2008 and Create a WPF Application and name the project as HideUnhideDGInWPF.

Here is the thing; we will have a DataGrid which will columns Auto Generated. We will have a Wrap Panel that will have the Check Boxes.
So here we go, add a class to generate sample data.

And create sample data and bind it to the DataGrid.

Now in the AutoGeneratedColumns event handler add the following code to generate the CheckBoxes.

Now we will work on the Hiding part for the Columns.

The following code is for un hiding the columns when uncheked.

That's it, we have actually done it. Run the application.

And when Checked or Unchecked, it will work.

Hope this article helps.

Jonad Garcia San MartinPosted Feb 10, 2015, 2:15 PM
please answer to my mail [email protected]
Jonad Garcia San MartinPosted Feb 10, 2015, 2:13 PM
Hello, great article. I want to do the same but using Caliburn.Micro. Is it possible. Sorry for my english.
Jonad Garcia San MartinPosted Feb 10, 2015, 2:12 PM
Hide & Un-Hide DataGrid Column(s) In WPF