How to hide DataGrid column in WPF automatically using MVVM?

前端 未结 1 1773
再見小時候
再見小時候 2021-02-12 09:29

Using MVVM (no code-behind), I want to hide my DataGrid columns upon selection, I have following code:



        
相关标签:
1条回答
  • 2021-02-12 09:48

    If you want to hide the Column, you need to specify the Property Visibility like this,

    YourDataGrid.Columns[IndexOftheColumn].Visibility = Visibility.Collapsed;
    

    If you want to Hide the first column say "Network ID"

    dg.Columns[0].Visibility = Visibility.Collapsed;
    
    0 讨论(0)
提交回复
热议问题