Tales from the Smart Client

John Gossman's observations on Avalon development

CollectionView

CollectionView is a very interesting construct.  After including it in my ViewModel I meant to quickly blog about the usage...but when I started thinking about it and reading a bit more about it, it becomes even more interesting.  Lots of good blogging.  However, while I think about it, let me quickly make my original point.

The Model has a simple List.  CollectionView wraps a Collection and adds concepts like selection, sorting and filtering to it and supports the INotify... goodness that data binding wants in order to do a really good job.  So, CollectionView is a construct that wraps a Model class and adapts it for data binding from the UI.  Uh...sounds like a ViewModel!

WPF does not use the terminology of M-V-VM, but it repeatedly uses the pattern.  CollectionView is a fine class name, but in very strict terms it isn't part of the View!  A CollectionView implies it has UI. 

If you really want to understand the M-V-VM pattern, there is no better place to start than to study how CollectionView adapts a Collection to be presented in the UI using data binding. 

Going to visit the in-laws, so blogging will be sporatic for awhile.

Published Tuesday, March 07, 2006 11:34 AM by JohnGossman

Comments

 

dhchait said:

John,  

This mirrors the concepts in System.Data of DataTable and DataView, where a DataView adds sorting and filtering on top of DataTable.

It's almost like a mini MVC model within the viewmodel - in there, you've got the DataTable (the Model), then you can have N DataViews "showing" different selections/sorts/etc on the underlying Table.  Update the table once, and all bound DataViews update accordingly.  Hence, DataView.

Sounds like CollectionView is analagous.
March 7, 2006 11:52 AM
 

Alex said:

I am not familiar with CollectionView ... do you have any links that would point the un-initiatied in the right direction?
March 12, 2006 7:24 AM
 

Life, Universe and Everything according to Dirk said:

John Gossman has posted the first part of his long-awaited example of a Model-View-ModelView architecture,...
March 14, 2006 7:01 AM
New Comments to this post are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker