WPF LIstView Binding to Column Headers

前端 未结 1 718
暖寄归人
暖寄归人 2021-01-16 19:15

I\'m attempting to create a listview that binds dynamically to a set of dates. So the user would b able to select a date range and the results for the chosen dates would sho

1条回答
  •  清歌不尽
    2021-01-16 19:46

    Try this way:

    
        
            
                
                    
                    
                        
                            
                                
                                
                            
                        
                    
                
            
        
    
    

    Apparently, the problem is that you are trying to bind to a property without specifying binding source and without having DataContext of the control set to anything. The reason why binding inside CellTemplate work is that the data context for rows is automatically set to the corresponding list item instance, but this is not true for headers - they inherit data context from the parent control. So, if we specify DataContext for the ListView then binding that is used in the header will be have a relative path to that data context: {Binding KPICollection.KPIResults[0].Date}

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