2

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はそれを表示しません。

何か案は?

4

1 に答える 1

4

DisplayMemberPathプロパティがすべてのINotifyPropertyChangedのものを含むビューモデル上にあることを確認します。つまり、プロパティは監視可能ですか?

于 2013-03-04T18:44:38.140 に答える