WPF datagrid header text binding

后端 未结 9 2299
执念已碎
执念已碎 2020-11-27 18:01

The column header of the DataGrid is not a FrameWork element for some reason, and so you cannot use bindings to set things like the header text. Please correct me if that is

9条回答
  •  我在风中等你
    2020-11-27 18:42

    This is the easy way to bind the DataGridTextColumn header to the data context:

    
           
                
                
                    
                        
                    
                
                
                    
                        
                    
                
            
        
    

    You will obviously need to have properties: SecondColumnTitle and ThirdColumnTitle implemented on your data context class.

    I have this solution working in .net 4.5 and did not have a chance nor reason to try it in earlier versions of the framework.

提交回复
热议问题