ListBox Double Click Event (Silverlight 4)

ListBox Double Click Event (Silverlight 4)

Old forum URL:

MadGerbil posted on Wednesday, September 21, 2011


I'd like a little direction on where I should look for a simple solution to my UI issue.  I've a list of users I display in a datagrid and in the details of the datagrid I've two listboxes: Available Groups and Current Groups.

I'd like to make it so if you double click on the Available Groups listbox the group that is selected will be added to the Current Groups listbox.   Pretty simple behavior.

Obviously, that isn't difficult to do in a ViewModel once you actually get to the view model.   I'm comfortable with commanding but that isn't available on a listbox.  It appears as if triggers may be the way to go with this but I'm not sure.   On the other hand, I could just add buttons to the UI and resort to commanding but double clicking is slicker.

So is a TriggerAction the way to go on this one?   Or would you recommend something else entirely?

Curelom replied on Wednesday, September 21, 2011

I believe you could use triggers for this.  You could also use one List Box to do the same thing where the selected items in the ListBox are the ones in the Current Groups using a technique from here

<ListBox Name="lstRoles" DisplayMemberPath="RoleName" 
ItemsSource="{Binding Source={StaticResource AvailableRolesViewSource}}"
ff:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding SelectedRoles}" 

Copyright (c) Marimer LLC