DataGridCheckBoxColumn loses IsReadOnly state when applying ElementStyle

后端 未结 2 1493
孤街浪徒
孤街浪徒 2021-01-18 08:01

I need to vertically center a DataGridCheckBoxColumn. Since I did not find a Property inside DataGridCheckBoxColumn, I applied an ElementStyl

2条回答
  •  没有蜡笔的小新
    2021-01-18 08:39

    I have a suspicion that this is a bug (as it doesn't happen on other column types).

    To work around it, all you need to do is make sure you base your style on the default style; by adding BasedOn="{x:Static DataGridCheckBoxColumn.DefaultElementStyle}" to the Style element:

    
        
            
                
                    
                
            
        
    
    

    This approach has the advantage that you don't have to do lots of work if you are intending on changing the DataGrid.IsReadOnly property at runtime.

提交回复
热议问题