0
我目前有一個HasChanges屬性的集合(集合中的每個對象也有它自己的HasChanges屬性),集合是我的CollectionViewSource的源。如何將數據綁定到collectionviewsource後面的集合的屬性?
當我嘗試將CollectionViewSource後面的集合的HasChanges屬性綁定到我的自定義控件之一時,它綁定到當前選定對象的HasChanges屬性,而不是CollectionViewSource源集合的HasChanges屬性。有沒有一種方法可以明確地告訴綁定查看集合對象而不是集合中的對象?
我的代碼看起來是這樣的:
<Window x:Class="CollectionEditWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Local="clr-namespace:My.Local.Namespace;assembly=My.Local.Namespace">
<Window.Resources>
<CollectionViewSource x:Name="CVS" x:Key="MyCollectionViewSource" />
</Window.Resources>
<Local:MyCustomControl HasChanges="{Binding HasChanges, Source={StaticResource
MyCollectionViewSource}}">
<!-- Code to set up the databinding of the custom control to the CollectionViewSource-->
</Local:MyCustomControl>
</Window>
感謝。