ObservableCollectionにバインドするWPFListViewがあります。
これが私のListViewです:
<ListView
BorderBrush="#6797c8"
BorderThickness="2"
ItemsSource="{Binding Path=MainCategoriesCollection, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="Category"
SelectedValuePath="MainCatID"
SelectedItem="{Binding MainCategorySelectedItem}"
SelectedIndex="{Binding MainCategorySelectedIndex, Mode=TwoWay}"
FontSize="14"/>
これは私のItemSourceです:
private ObservableCollection<DataModel.MainCategories> mainCategoriesCollection;
public ObservableCollection<DataModel.MainCategories> MainCategoriesCollection
{
get
{
if (mainCategoriesCollection == null)
{
mainCategoriesCollection = new ObservableCollection<DataModel.MainCategories>();
}
return mainCategoriesCollection;
}
set
{
mainCategoriesCollection = value;
RaisePropertyChanged("MainCategoriesCollection" );
}
}
配線に問題があります。MainCategoriesCollectionからアイテムを追加したり、アイテムを削除したりすると、ListViewは問題なく更新されますが、特定のアイテムを取得して「DisplayMemberPath」を表すitemプロパティを変更すると、ListViewに変更が表示されません。問題をデバッグし、変更がMainCategoriesCollectionに存在することを確認しましたが、ListViewはそれを表示しません。
何か案は?