Hi,
I have 3 ListBoxes in my app.
ListBox_01
ItemsSource="{Binding EmployeeViewM.MainActivity}"
EmployeeViewM is a ViewModel defined in ViewModelLocator using Ioc.
MainActivity is a ObservableCollection bind to the Model - table with activities via EntityFramework.
- SelectionMode = "Multiple"
- Limit to selected items set to 2
<i:Interaction.Behaviors>
<listb:ListBoxSelectedItemBehavior SelectedItems="{Binding EmployeeViewM.SelectedAll, Mode=TwoWay}"/>
<limit:LimitSelectionBehavior Limit="2"/>
</i:Interaction.Behaviors>
- listb:ListBoxSelectedItemBehavior is an attached property to enable SelectedItems from ListBox
public static readonly DependencyProperty SelectedItemsProperty = DependencyProperty.Register("SelectedItems", typeof(ObservableCollection<object>), typeof(ListBoxSelectedItemBehavior), new PropertyMetadata(new ObservableCollection<object>(), PropertyChangedCallback));
- SelectedAll is a property on EmployeeViewM ViewModel for SelectedItems (IList):
private IList _selectedAll = new ArrayList();
public IList SelectedAll {
get { return _selectedAll; }
set {
_selectedAll = value;
RaisePropertyChanged("SelectedAll");
}
}
ListBox_02 is the same like ListBox_01, the only difference is that it is bind to another table (NonProcess)
Employees are able to select items on both - max 2 items per ListBox.
All selected items will be visible in ListBox_03.
ItemsSource="{Binding EmployeeViewM.SelectedAll}"
ItemsSource for this ListBox is SelectedAll.
This part works great, but, when employee click on the item in the ListBox_03 I would like to:
- get that selected item name and other attributes from table that it comes from (MainActivity or NonProcess) - best in columns (from IList columns are unknown)
- save that item via .SaveChanges() to another table
What I have tried:
IsSelected - Not able to bind to that property,
ICollection instead IList, ObservableCollection(of Object)