我试图让我ListCollectionView
绑定到一个组合框。但是,它似乎只在我绑定到我的ObservableCollection
.
特性:
private ListCollectionView sitesView;
public ListCollectionView SitesView
{
get { return sitesView; }
set
{
sitesView = value;
RaisePropertyChanged(() => SitesView);
}
}
public ObservableCollection<ISite> SitesCollection { get; set; }
构造函数:
SitesCollection = new ObservableCollection<ISite>();
SitesView = (ListCollectionView)CollectionViewSource.GetDefaultView(SitesCollection);
像这样绑定时:
<ComboBox Grid.Row="2" ItemsSource="{Binding SitesView, Mode=TwoWay}"/>
当我单击组合框中的下拉菜单时,我添加的任何项目SitesCollection
都不会显示。但是,如果我像这样进行绑定:
<ComboBox Grid.Row="2" ItemsSource="{Binding SitesCollection, Mode=TwoWay}"/>
它工作正常,当我单击下拉菜单时我会看到这些项目。
修复尝试:在将 an 项目添加到 后SitesCollection
,我尝试在 theListCollectionView
和 the上发出属性更改通知ObservableCollection
,但没有任何区别。有任何想法吗?