Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'll come back and add more detail to this later, but here's basically what I think needs to happen.</p> <p>The click should have a <code>DelegateCommand</code> type implementation, that contains a reference to the view models of both A and B. You need some kind of "conductor" class that is instantiating the view models, and which can pass the appropriate references into the command object.</p> <hr/> <p>So, clearly the command belongs in the View Model for A, <em>but</em>, it needs a reference to B. So set up the command class with that in mind:</p> <pre><code>public MyCommand : ICommand { private readonly ViewModelA _a, ViewModelB _b; public MyCommand(ViewModelA a, ViewModelB b) { _a = a; _b = b; } public bool CanExecute(object arg) { // can-execute logic here } public void Execute(object arg) { _b.StateDataRequestedCommand.Execute(""); _a.ProcessInfoRequestedCommand.Execute(""); } } </code></pre> <p>Now, but an instance of <em>MyCommand</em> into A's View Model...</p> <pre><code>public MyCommand StateRequestedCommand { get; set; } </code></pre> <p>And bind to it as normal...</p> <pre><code>&lt;telerik:RadButton Command="{Binding StateRequestedCommand}" /&gt; </code></pre> <p>Now, the challenge is to instantiate this class within A's View Model somehow. I normally use NInject to inject external dependencies into classes, but there are different ways to do it. Either way, it has to happen at a higher level than ViewModelA itself, since it doesn't have a reference to ViewModelB. That could be in the App_Startup logic, or in IoC (eg, NInject) bindings, or in a View Model "Locator", if that's what you're using.</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.
 

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