Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had <a href="http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=50763" rel="nofollow noreferrer">exactly the same problem</a> when I first went through Prism.</p> <p><code>Controllers</code> are basically for logic that spans an entire module, whereas <code>Presenters</code> are for logic that is specific to a <code>View</code>.</p> <p>For example, a <code>Presenter</code> would respond to a command that results in a button in the view being disabled. A <code>Controller</code> would respond to a command that results in the <code>View</code> (and <code>Presenter</code>) being changed entirely, or perhaps loading a different View/Presenter in a different region in the module's shell.</p> <p><strong>Edit:</strong> As for when to use them, you can skip the <code>Controller</code> entirely if you have no need for the orchestration mentioned above. The simplest application will just have a:</p> <ul> <li><code>Module</code>: registers the view/presenter into the <code>Region</code></li> <li><code>Presenter</code>: responds to commands from the view and modifies the <code>ViewModel</code>.</li> <li><code>ViewModel</code>: adapter between <code>Presenter</code> and <code>View</code> that implements <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx" rel="nofollow noreferrer"><code>INotifyPropertyChanged</code></a></li> <li><code>View</code>: binds to <code>ViewModel</code> and displays UI</li> </ul> <p><strong>Edit:</strong> As for Presenter vs ViewModel, most of your logic should be in your Presenter. Think of your ViewModel as housing the logic for your view, but the Presenter as dealing with the consequences of interacting with the view.</p> <p>For example, the user clicks the "Search" button in your <code>View</code>. This triggers an <code>ICommand</code>, which is handled by your <code>Presenter</code>. The <code>Presenter</code> begins the search and sets the <code>ViewModel.IsSearching</code> property, which fires the PropertyChanged notification for <code>CanSearch</code>. <code>CanSearch</code> is a readonly property that is based on several other properties (eg. <code>IsSearchEnabled &amp;&amp; !IsSearching</code>). The "Search" button in the <code>View</code> has its <code>Enabled</code> property bound to <code>CanSearch</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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