Hi,
My Scenario:
Two ListBoxes -
Listbox_01 and
Listbox_02.
Listbox_01 ItemsSource is bind to a ObservableCollection in a ViewModel, SelectionMode set to Multiple, with attached property to limit the selection to 2 items. SelectedItems (dependency property) is bind to a property (IList) on ViewModel
Listbox_02 ItemsSource is bind to a property (IList) on a ViewModel (SelectedItems from Listbox_01). SelectionMode set to Single.
When I select items from Listbox_01 all should appear in a Listbox_02. This works for me. The question is,
How can I link these two Listboxes to select and deselect items between them.
If I select two items from Listbox_01 they will be visible in Listbox_02. Then, when I select item from Listbox_02 it should get selected item (columns or content), fire command (RelayCommand), deselect that item on Listbox_01 and disappear from Listbox_02.
The problem here is that, when I click on Listbox_02 item there is always selection on Listbox_01 and the item that disappear from Listbox_02 is not correct (when I have two items, I click on the item_02 to close it, item_01 disappears)
Listbox_01 is only for selecting items. Listbox_02 is to execute command.
My code:
Listbox_01
<listv:ListViewSelectedItemBehavior SelectionMode="Multiple"
ItemsSource="{Binding EmployeeViewM.MainActivity}"
SelectedItemsList="{Binding EmployeeViewM.SelectedAll, Mode=OneWayToSource}"
Background="{x:Null}"
BorderBrush="{x:Null}"
IsSynchronizedWithCurrentItem="False" >
Listbox_02
<listv:ListViewSelectedItemBehavior SelectionMode="Single"
HorizontalAlignment="Left"
ItemsSource="{Binding EmployeeViewM.SelectedAll}"
SelectedItemsList="{Binding EmployeeViewM.SelectedAll, Mode=TwoWay}"
Background="{x:Null}"
BorderBrush="{x:Null}"
IsSynchronizedWithCurrentItem="False">
SelectedAll IList
Public Property SelectedAll() As IList
Get
Return _selectedAll
End Get
Set(value As IList)
_selectedAll = value
RaisePropertyChanged("SelectedAll")
End Set
End Property
What I have tried:
SelectedIndex, SelectedItem, DataGrid instead of ListBox,