Click here to Skip to main content
15,921,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody,

I've got a DataGrid with a number of columns, which I've manually defined in xaml.
<DataGrid ItemsSource="{Binding SearchResult}" AutoGenerateColumns="False">
       <DataGridTextColumn Header="Column1" Binding="{Binding Property1}" />
       <DataGridTextColumn Header="Column2" Binding="{Binding Property2}" />

Now I'd like to have a ContextMenu in which each column has a MenuItem with checkbox to hide or show the Column.
<ConextMenu ItemSource="{Binding Columns}">
      <MenuItem.Icon><CheckBox IsChecked="{Binding IsVisible}" /></MenuItem.Icon>
      <MenuItem.Header><TextBlock Text="{Binding ColumnHeader}" /></MenuItem.Header>

How can I implement this with Bindings?

Thanks a lot for your reply.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900