EventToCommand for the ListBox selectedItems

Dec 16, 2010 at 10:34 PM

Hi,

I need to select multiple items from a ListBox. Since "SelectedItems is not a DependencyProperty", I have created a EventToCommand as given in the MVVM Light sample for the datagrid.

 <ListBox x:Name ="LeftListBox" Grid.Row="1" Grid.Column="1"  Width="100" HorizontalAlignment="Right" Height="250" SelectionMode="Extended"  ItemsSource="{Binding Path=LeftSearchFields}">
      <i:Interaction.Triggers>
         <i:EventTrigger EventName="SelectionChanged">
         <cmd:EventToCommand
          Command="{Binding LeftListSelectionChangedCommand, Mode=OneWay}"
          CommandParameter="{Binding SelectedItems, ElementName=LeftListBox}"
         />
      </i:EventTrigger>
     </i:Interaction.Triggers>
 </ListBox>

 

However, the Command parameter - "SelectedItems" doesnt seem to hold the selectedItems at all. Is there anything I am missing?

Thanks

 

   


Coordinator
Dec 17, 2010 at 12:41 AM

Hi,

In what platform?

In Silverlight, SelectedItems is not a dependency property, so bindings to that property are OneTime only. The binding is not updated when the value changes.

Laurent