Note that there are some explanatory texts on larger screens.

plurals
  1. POSL ItemsControl, command on ViewModel not firing from ItemsControl (CheckBox)
    text
    copied!<p>I'm using PRISM v2, CAL, SL4 and MVVM and have a delegate command on my ViewModel called CheckCommand. The ItemsControl contains a checkbox and I'm trying to get the items in ItemsControl/Checkbox to fire this command when it's checked - but it's not communication back to the viewmodel!</p> <p>I think it's because each items 'datacontext' is the individual object the item is bound to, rather than the ViewModel?<br> - My suspicion is actually correct, cause if I move my DelegateCommand out of the viewmodel and into the class defining the items in itemscontrol I can see the commands/methods beeing fired!</p> <p>View:</p> <pre><code>&lt;ListBox x:Name="BasketListBox" ItemsSource="{Binding BasketCollection}" MinWidth="200"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;CheckBox commands:Checked.Command="{Binding CheckCommand}" IsChecked="False" &lt;/CheckBox&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; </code></pre> <p></p> <p>Can anyone point me in the right direction please?</p> <p>Cheers, Mcad.</p> <p>EDIT 1:</p> <p>The commanding now works, see solution below. BUT, I now run into another problem:<br> "An exception occurred while creating a region with name 'basketRegion'. The exception was: System.InvalidOperationException: ItemsControl's ItemsSource property is not empty. This control is being associated with a region, but the control is already bound to something else. If you did not explicitly set the control's ItemSource property, this exception may be caused by a change in the value of the inherited RegionManager attached property"</p> <p>Created seperate question for this problem to make it more clean:</p> <p><a href="https://stackoverflow.com/questions/4022303/prism-mvvm-itemscontrol-problem-with-view-injection">PRISM-MVVM, ItemsControl problem with View injection</a></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