Binding WPF Datagrid cell background colour with trigger

后端 未结 2 446
耶瑟儿~
耶瑟儿~ 2021-01-02 00:33

I want the background colour of a WPF datagrid cell to change colour when the contents have been modified. Each cell has behind it a ViewModel object which contains the foll

2条回答
  •  醉话见心
    2021-01-02 00:54

    You need to set CellStyle to target DataGridCell instead of only TextBlock.

    If you want this dataTrigger to be applied for all cells in your dataGrid, set style on DataGrid CellStyle otherwise you can do that on specific DataGridTextColumn CellStyle as well.

    DataGrid

         
            
                
            
        
    

    DataGridTextColumn

         
            
                
                    
                        
                    
                
            
        
    

提交回复
热议问题