0

私は複合コレクションを持っています。コードビハインドからアイテムを変更した後、ビューを更新したいと思います。しかし、ビューに通知する方法がわかりません。を試してみましたINotifyCollectionChangedが、うまくいきませんでした。

    protected ObservableCollection<ScriptParameterComboItem> cItems

    public virtual CompositeCollection CItems
    {
        get
        {
            return new CompositeCollection {new CollectionContainer {Collection = cItems}};
        }
    }

    public void ConvertValue(params object[] parameters)
    {
        string newAverageOption = DisplayValueConverter.Convert(1, parameters);
        var enumItem = cItems[1];
        enumItem.Value = newAverageOption;
        RaiseCollectionChanged("CItems");
    }


    protected void RaiseCollectionChanged(string property)
    {
        if(CollectionChanged != null)
            CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add));
    }
4

1 に答える 1

1

クラスScriptParameterComboItemは を実装する必要がありますINotifyPropertyChanged。そのため、プロパティを変更すると、リスナーに通知されます。を使用すると、コレクションに何かが追加されたり、コレクションから削除さObservableCollectionれたりしたときに、リスナーに通知を受け取ることができます。すべてのアイテム内の実際のデータを変更するわけではありません。

于 2013-04-02T10:08:16.770 に答える