2016-10-20 14 views
2

観察可能なコレクションが内部リストの変更を通知できるかどうか?オブジェクトリストの観察可能なコレクション

ObservableCollection<List<TimeSeriesData>> ChartLines = 
new ObservableCollection<List<TimeSeriesData>>(); 

変更を通知することができるかどうかをリストしますか?

+1

「ObservableCollection」は、_it_が変更された場合に通知します。それはあなたが保持しているアイテムの変更について何も教えてくれません。 –

+0

@JeffMercado thankyou –

答えて

1

あなたのTオブジェクトのINotifyPropropertyChangedを実装する必要がありますし、あなたのObservableCollectionが表現されたプロパティのために:

private ObservableCollection<MyViewModel> _myCollection; 
    public ObservableCollection<MyViewModel> MyCollection 
    { 
     get 
     { 
      return _myCollection; 
     } 
     set 
     { 
      _myCollection= value; 
      OnPropertyChanged(); 
     } 
    } 

をあなたはまた、MyViewModelのすべてのメンバーのINotifyPropropertyChangedを実装する必要があります。

public class MyViewModel : ViewModelBase 
{ 

    private string _myProperty; 
    public string MyProperty 
    { 
     get { return _myProperty; } 
     set 
     { 
      _myProperty= value; 
      OnPropertyChanged(); 
     } 
    } 
} 

AddinionallyますXAML for MyPropertyのUpdateSourceTriggerを忘れてはならない。実行時に更新を確認したい場合:

<TextBox Text="{Binding MyProperty, UpdateSourceTrigger=PropertyChanged}"/> 

私はあなたに役立つことを願っています。

関連する問題