CompositeCollection + CollectionContainer: Bind CollectionContainer.Collection to property of ViewModel that is used as DataTemplates DataType

后端 未结 2 1921
暖寄归人
暖寄归人 2020-12-03 03:52

I do not get the correct Binding syntax to access the Cats and Dogs properties of MyViewModel within a DateTemplate that

2条回答
  •  Happy的楠姐
    2020-12-03 04:00

    Due to the issue with data binding on CollectionContainer as described http://social.msdn.microsoft.com/Forums/vstudio/en-US/b15cbd9d-95aa-47c6-8068-7ae9f7dca88a/collectioncontainer-does-not-support-relativesource?forum=wpf I now use the following approach:

    
      
        
        
      
      
        
          
          
        
      
      
    
    

    Edit: The CompositeCollection class does not derive from FrameworkElement and thus does not have a DataContext property to support data binding. It will only work if you use Binding providing a Source. Have a look here https://stackoverflow.com/a/6446923/1254795 for more information.

提交回复
热议问题