Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The standard approach with MVVMLight is the split your view-model into data and commands. Most things you use databinding related, properties, etc. but commands actually do something. </p> <p>In this case what you are calling "Fire Method 1" is an ordinary method that to conform to the pattern you have to convert to a command. If you already have commands you know what I am talking about.</p> <p>The glue for events like <code>SelectionChanged</code> that you would have wired up with code-behind in MVVMLight is <code>EventToCommand</code> which is a XAML fragment that you put in the XAML with the pivot item instead of in the event hander.</p> <p>So this is the pattern: <code>EventToCommand</code> is your key to hooking up XAML events to view-model commands <strong>without</strong> any code-behind. The best thing to do is use the MVVMLight samples to see how <code>EventToCommand</code> works because there are lots of ways to use it.</p> <p>But here is the bare-bones version:</p> <pre><code>&lt;controls:PivotItem Name="pivotItem"&gt; &lt;i:Interaction.Triggers&gt; &lt;i:EventTrigger EventName="SelectionChanged"&gt; &lt;cmd:EventToCommand Command="{Binding SelectServiceCommand}" CommandParameter="{Binding SelectedIndex, ElementName=pivotItem}"/&gt; &lt;/i:EventTrigger&gt; &lt;!-- other stuff --&gt; &lt;/i:Interaction.Triggers&gt; &lt;/controls:PivotItem&gt; </code></pre> <p>and to make this work the <code>SelectServiceCommand</code> has to actually exist in the view-model and it has to take a parameter and do the right thing for 0, 1, 2, 3, etc.</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.
    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.
    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