I thought I should add a post with the full list of posts in the D-V-VM pattern. They are:
DataModel-View-ViewModel pattern: 1 (overview)
DataModel-View-ViewModel pattern: 2 (first implementation of DataModel class)
DM-V-VM part 3: A sample DataModel
DM-V-VM part 4: Unit testing the DataModel
DM-V-VM part 6: Revisiting the data model
Dan Crevier has series of posts on the DM-V-VM pattern, including how to implement it and how ot test
Thanks! Now you just need a DM-V-VM tag so that all your posts come up in one place. 🙂
Thanks this was great.
I specially liked the way you injected control into the StockModel [StockModel(symbol, IStockQuoteProvider)]
To be honest, I had some difficulty grasbing the why & how of the ActivateModel. I had to really think about it, but I think I get it now…with that said, would you please give an example of why you needed to do reference counting? In other words: For which scenarios the ActiviateModel you described isn’t good enough?
Thanks again.
Houman
I may have included one of those in one of my link roundups, but this is a topic very dear to my heart
One example scenario where I needed ref counting in the activation was in Max when we had nested views where the inner view’s template was chosen programmatically based on the model state. Both the outer view and inner view needed to activate the model. If you don’t need this, no need to add the complexity.
Thanks for a post, it is very good. Currently I am working on creating a back end accounting application with WPF. Since we anticipate many calls to service layer (WCF), I liked the concept of DataModel. It was curious that the constructor of the viewModel DataModel is doing actual data extraction. I would have thought you will have separate GetData Method. Usually I try to perform minimal task in constructors.
I am also struggling about how to write an automated unit test for the PortfolioViewModel equivalent. To test the behavior of AddCommandModel and RemoveCommandModel etc. Any information you can provide in that domain can be helpful.
Actually the data extraction really happens when the model is activated.
To unit test AddCommandModel/RemoveCommandModel, you can set up some test data in PortfolioViewModel. Then, you can get the commands through the PropertyViewModel accessors and call OnQueryEnabled and OnExecute with different parameters to try it out. In cases where you need to get to private methods and data, use PrivateObject or PrivateType.
I tried to use your suggestion to call OnQueryEnabled and OnExecute directly. I keep getting error "The type CanExecuteRoutedEventArgs has no constructors defined". I am not able to find any sample which directly instantiates this class.
My aim is to create a console application to test the behavior of presenter. I guess if I create a windows based application I can use command binding and test this via Command object. But not sure how to do this in Console app.
You can use Visual Studio’s PrivateObject helper class to help out:
Type[] types = { typeof(ICommand), typeof(object) };
object[] param = { myRoutedCommand, null };
PrivateObject privateCanExecuteArgs = new PrivateObject(typeof(CanExecuteRoutedEventArgs), types, param);
CanExecuteRoutedEventArgs canExecuteArgs = (CanExecuteRoutedEventArgs)privateCanExecuteArgs.Target;
You can do this from a command line app.
Regarding multiple parameters for the CommandModel: what if we set the ViewModel as the parameter for the CommandModel. This way the CommandModel can be the link between the ViewModel and the DataModel and can validate against N number of values.
Yes, that would definitely work. If you do things through an interface, it will keep the command from being specific to one view model.
I’ve been meaning to document how I wrapped the Twitter API … in 4.5 seconds. There is a very powerful
I've been meaning to document how I wrapped the Twitter API … in 4.5 seconds. There is a very powerful
Introduction I've been posting a lot about Silverlight lately, but hey, here is a WPF post, and about
Tonight I presented for the Dayton .Net Developers Group on WPF. Unlike my previous Lap Around WPF @
In this post (of what may become a series of posts if I find some interest from the community) I compare
First I'd like to say that I'm stoked about the work the Prism team has been doing.  I have
This post is based on an interpretation of a pattern called View-View Model-Document or View-View Model
Après avoir participé à quelques projets WPF depuis maintenant un peu plus d’un an, je suis dans une
Après avoir participé à quelques projets WPF depuis maintenant un peu plus d’un an, je suis dans une
Checking out DataModel ViewModel patterns.
Table of Contents Since my last post on building ChumChase, I've had a couple of projects that have
Table of Contents Since my last post on building ChumChase, I've had a couple of projects that have
Table of Contents Since my last post on building ChumChase, I've had a couple of projects that have
Serie Tutorial Pattern DM-V-VM
Вторая часть из серии постов, в которых мы последовательно пройдем все этапы соз
In this article I will explain how to implement MVVM pattern in Silverlight. I was very overjoyed when
#.think.in infoDose #21 (10th Mar – 15th Mar)
都是Silverlight做的游戏
http://www.silverarcade.com/Games