WPF DataGridTemplateColumn shared template?

前端 未结 1 1869
梦毁少年i
梦毁少年i 2021-01-12 20:15

Hi I have a datagrid that has a number of datagridtemplate columns that are all identical apart from they each have a different datacontext on the template\'s stackpanel.

1条回答
  •  失恋的感觉
    2021-01-12 20:48

    You could use a ContentPresenter to instantiate a DataTemplate for each column:

    
        
            
                
            
        
    
    
        
            
                
                    
                
            
        
        
            
                
                    
                
            
        
    
    

    If the elements of Times are all the same type, you could also do and then you wouldn't need to specify ContentTemplate="{StaticResource ColumnTemplate}" on each column.

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