WPF DataGrid: Binding DataGridColumn visibility to ContextMenu MenuItems IsChecked (MVVM)

后端 未结 6 637
不思量自难忘°
不思量自难忘° 2020-12-23 23:45

I want to control DataGrid column visibility through a ContextMenu available to the user by right-clicking the column header. The ContextMenu

6条回答
  •  清歌不尽
    2020-12-24 00:10

    I know this is a bit old. But I was looking at doing this and this post is much simpler: http://iimaginec.wordpress.com/2011/07/25/binding-wpf-toolkit%E2%80%99s-datagridcolumn-to-a-viewmodel-datacontext-propogation-for-datagrid-columns-the-mvvm-way-to-interact-with-datagridcolumn/

    All you need to do is set DataContext on the Columns and then bind Visibility to your ViewModel as per normal! :) Simple and effective

提交回复
热议问题