Disable selecting in WPF DataGrid

后端 未结 12 848
天命终不由人
天命终不由人 2020-12-14 05:30

How can I disable selecting in a WPFTooklit\'s DataGrid? I tried modifying the solution that works for ListView (from WPF ListView turn off selecti

12条回答
  •  一向
    一向 (楼主)
    2020-12-14 06:04

    To completely disable selection of rows in a DataGrid, you could do the following:

    
        
            
        
        
    
    

    This could be considered more favorable than setting due to the fact that doing the aforementioned technique causes the style of the row to change. It also does not disable context menus from appearing when right-clicking.

    Lastly: it is important to note that setting "IsHitTestVisible" to "False" disables all interaction with the rows, including editing.

    However, if all you want to do is change the styling of the row when selected, please view the answers here.

提交回复
热议问题