Updating datagrid from stream with data binding ObservableCollection

I am new to WPF and MVVM, and I started with “Jason Dolinger on Model-View-ViewModel” in the article and example, but I have some questions regarding data binding.

1) In his demo application, he subclasses DependencyObject for ObservableCollection elements. What are the pros and cons compared to INotifyPropertyChanged?

2) What is the best way to update a view from a model in a datagrid / listview? In his example, he registers as a listener when a Quote object is added or updated:

_source.QuoteArrived += new Action<Quote>(_source_QuoteArrived);

How the ViewModel creates and adds a QuoteViewModel to the collection OR updates the view by installing the updated Quote object in a convenient QuoteViewModel using a dictionary called _quoteMap.

void _source_QuoteArrived(Quote quote)
{

    QuoteViewModel qvm;
    if (_quoteMap.TryGetValue(quote.Symbol, out qvm))
    {
        qvm.Quote = quote;
    }
    else
    {
        qvm = new QuoteViewModel();
        qvm.Quote = quote;

        this.Quotes.Add(qvm);

        _quoteMap.Add(quote.Symbol, qvm);
    }
}   

, Quote dictionnary? , Quote... INotifyPropertyChanged DependencyObject.

+3
1

. fooobar.com/questions/19927/.... INotifyPropertyChanged.

, , , - , , . . ?

, ListView, ListView , ? ListView , INotifyCollectionChanged, Quote Quote.Symbol

+1

All Articles