DataGridTextColumn Header DataTemplate

后端 未结 1 852
情话喂你
情话喂你 2020-12-20 17:17

This may (hopefully) have a trivial or very simple answer.

Suppose I want customized headings for my DataGrid. I can use a DataTemplate as

1条回答
  •  一个人的身影
    2020-12-20 17:42

    You can do it by binding TextBlock.Text and you can do it either for all column headers in a DataGrid by changing ContentTemplate of header to be your custom TextBlock and then just set Header to text you want to display. It will also apply to automatically generated columns

    
       
          
       
       
          
       
           
    

    or can also do it per column just change TextBlock.Text in you header template to use binding, as above

    
    

    and then you column could look like this:

    
    

    0 讨论(0)
提交回复
热议问题