title: MVVM in WPF - How to alert ViewModel of changes in Model... or should I?
body: <p>I am going through some MVVM articles, primarily <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx">this</a> and <a href="http://rachel53461.wordpress.com/2011/05/08/simplemvvmexample/">this</a>.</p>
  
  <p>My specific question is: <strong>How do I communicate Model changes from the Model to the ViewModel?</strong> </p>
  
  <p>In Josh's article, I don't see that he does this. The ViewModel always asks the Model for properties. In Rachel's example, she does have the model implement <code>INotifyPropertyChanged</code>, and raises events from the model, but they are for consumption by the view itself (see her article/code for more detail on why she does this).  </p>
  
  <p>Nowhere do I see examples where the model alerts the ViewModel of changes to model properties.  This has me worried that perhaps it's not done for some reason.   <strong>Is there a pattern for alerting the ViewModel of changes in the Model?</strong>  It would seem to be necessary as (1) conceivably there are more than 1 ViewModel for each model, and (2) even if there is just one ViewModel, some action on the model might result in other properties being changed. </p>
  
  <p>I suspect that there might be answers/comments of the form "Why would you want to do that?" comments, so here's a description of my program.  I'm new to MVVM so perhaps my whole design is faulty.  I'll briefly describe it.</p>
  
  <p>I am programming up something that is more interesting (at least, to me!) than "Customer" or "Product" classes.  I am programming BlackJack.  </p>
  
  <p>I have a View that doesn't have any code behind and just relies on binding to properties and commands in the ViewModel (see Josh Smith's article).  </p>
  
  <p>For better or worse, I took the attitude that the Model should contain not just classes such as <code>PlayingCard</code>, <code>Deck</code>, but also the <code>BlackJackGame</code> class that keeps state of the whole game, and knows when the player has gone bust, the dealer has to draw cards, and what the player and dealer current score is (less than 21, 21, bust, etc.). </p>
  
  <p>From <code>BlackJackGame</code> I expose methods like "DrawCard" and it occurred to me that when a card is drawn, properties such as <code>CardScore</code>, and <code>IsBust</code> should be updated and these new values communicated to the ViewModel. Perhaps that's faulty thinking?  </p>
  
  <p>One could take the attitude that the ViewModel called the <code>DrawCard()</code> method so he should know to ask for an updated score and find out if he is bust or not.  Opinions?  </p>
  
  <p>In my ViewModel, I have the logic to grab an actual image of a playing card (based on suit,rank) and make it available for the view. The model should not be concerned with this (perhaps other ViewModel would just use numbers instead of playing card images).  Of course, perhaps some will tell me that the Model should not even have the concept of a BlackJack game and that should be handled in the ViewModel?</p>