Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I make Message targets be the only recipent of a targeted Message?
    primarykey
    data
    text
    <p>First time poster. </p> <p>I'm using MVVM-Light with Silverlight 4 and RIA Services. This has been a learning experience! But so far, it's working <em>beautifully</em>. I was wondering two things. Right now, I'm using the Messenger framework to pass EntityObjects back to the ViewModel. For instance, I need to open a View Model with a specific "Course" object. So I instantiate the View, and the View sends a Message to the ViewModel with the Course. I've got a couple questions.</p> <p>First question: Is this the best way to do this? I don't want to use Prism or Unity or any of those other things because I don't have the time to learn them. (This was, for me, the big draw of MVVM Light. The Light part.) But I couldn't see any other way to pass parameters to the VM Locator.</p> <p>The second part is, this means I am sending messages from the View to that View's specific ViewModel. My messages look like this:</p> <pre><code> Tuple&lt;Models.Course, Services.VWDS&gt; courseDomainContextTuple = new Tuple&lt;Models.Course, Services.VWDS&gt;(Course, DomainContext); NotificationMessage&lt;Tuple&lt;Models.Course, Services.VWDS&gt;&gt; message = new NotificationMessage&lt;Tuple&lt;Models.Course, Services.VWDS&gt;&gt;(this, this.DataContext, courseDomainContextTuple, Models.MessageString.EditCourse); Messenger.Default.Send&lt;NotificationMessage&lt;Tuple&lt;Models.Course, Services.VWDS&gt;&gt;&gt;(message); </code></pre> <p>So, as you can see, I'm bundling the Course and the DomainContext (Ah RIA. Why won't you let me get the Context from the EntityObject?) and sending them to the ViewModel (which is "this.DataContext") - and yes, I know I should make a class for that message. </p> <p>Here's the problem - every object that gets a Course and a DomainContext receives that message, not just the VM that I've designated the Target.</p> <p>So, second question: Is that by design, or is that a bug, or am I doing something wrong?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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