How to show/hide column(s) in ListView?

Unfortunately there is no Visibility property in GridViewColumn in WPF. The only workaround to hide the column is setting the width property to ‘0’, to show the column is either setting the width to auto or set it to the original width value.

Add a name to the GridViewColumn in XAML.

<GridViewColumn Header="Age" x:Name="ageColumn">

In your code, set the width for the gridview column.

//to hide the column set width as 0.
ageColumn.Width = 0;

//to show the column set width as auto.
ageColumn.Width = double.NaN;



You may also want to refer this site.

http://i-zaak.eu/Lists/Posts/Post.aspx?ID=5

No comments:

Post a Comment