Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In such a case I'd normally use a Messenger (e.g. MVVMLight) / Mediator / EventAggregator (e.g. Prism) patterns to notify the View that it should execute the method. With such a pattern you basically send a message from the VM to some recipient (in your case the View) without knowing who will handle it. Thus the view model does not need to know the view. </p> <p>Furthermore, this pattern can be used to create general broadcast messages that can be handled my many recipients, without the sender knowing any of them.</p> <p>Examples:</p> <ul> <li><a href="http://geekswithblogs.net/lbugnion/archive/2011/01/06/navigation-in-a-wp7-application-with-mvvm-light.aspx" rel="nofollow noreferrer">Realizing Navigation in WP7</a></li> <li><a href="http://stevenhollidge.blogspot.de/2011/05/mvvmlight-messenger-for-loosely-coupled.html" rel="nofollow noreferrer">MVVMLight Messenger for Loosely Coupled Events</a></li> <li><a href="http://sachabarbs.wordpress.com/2009/03/16/mvvm-mediator-pattern/" rel="nofollow noreferrer">MVVM Mediator Pattern</a></li> <li><a href="http://neverindoubtnet.blogspot.de/2009/05/event-aggregator-in-prism-explorer.html" rel="nofollow noreferrer">Event Aggregator in Prism</a></li> </ul> <p>and </p> <ul> <li><a href="https://stackoverflow.com/search?q=user%3A266919+messenger">Some of my ramblings on the MVVMLight messenger</a></li> </ul> <p><strong>PS:</strong> </p> <p>There are many valid cases for such an approach. However, it must be said that calling the View from the ViewModel should be avoided, if there is another solution. </p> <p>To those who criticise the access to the view from the view model: Please keep in mind that MVVM is about empowering the user by giving her alternatives, not forcing rules upon them.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload