Disable DataGrid current cell border in FullRow selection mode

后端 未结 7 960
走了就别回头了
走了就别回头了 2020-12-24 00:19

I am using a DataGrid in row selection mode (i.e., SelectionUnit=\"FullRow\"). I simply want to remove the border that is being placed around the current cell w

7条回答
  •  醉话见心
    2020-12-24 00:55

    In case you don't want to mess with XAML styles you could do this simple hack. It does not work as good as XAML styles but you can try it out and see if it fits you. It is fine for simple clicking on cells but if you try to drag cells this won't remove focus afterwards (although I am pretty sure you could add another case which checks for that).

    private void YourDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        YourDataGrid.Focus();
    }
    

    PS: Don't forget to add the event handler to your DataGrid's SelectionChanged property.

提交回复
热议问题