I'm developing a Windows Phone 8.1 app with MVVM pattern (I'm using Prism as a framework)
The goal is to get the selected items in a few lists, like that:
I have following XAML:
<ListView
x:Name="abc"
ItemsSource="{Binding Symbols}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<ListBox
SelectionMode="Multiple"
ItemsSource="{Binding List}"
Extensions:ListViewExtensions.BindableSelection="{Binding SelectedItems, ElementName=abc, Mode=TwoWay}">
...
and in the ViewModel:
public List<SymbolsGroupViewModel> Symbols {
get { return _symbols ?? (_symbols = _dataService.Symbols.GetGroupViewModels()); }
set { _symbols = value; }
}
where class SymbolsGroupViewModel
looks like that:
public class SymbolsGroupViewModel : ViewModel
{
private readonly INavigationService _navigationService;
private readonly DataService _dataService;
private ObservableCollection<Symbol> _selectedItems = new ObservableCollection<Symbol>();
public SymbolsGroupViewModel(INavigationService navigationService, DataService dataService)
{
_navigationService = navigationService;
_dataService = dataService;
}
public SymbolsGroupViewModel() { }
public Symbol Header { get; set; }
public List<Symbol> List { get; set; }
public ObservableCollection<Symbol> SelectedItems
{
get { return _selectedItems; }
set { SetProperty(ref _selectedItems, value); }
}
}
It is supposed to use the BindableSelection
extension from WinRT XAML Toolkit, like here:
https://stackoverflow.com/a/25430935/5194338
It works for me with NOT nested lists, however when I adapt the solution to nested list, the SelectedItems
lists contain 0 elements.
Does anybody know if it is possible to use this extension in nested lists and if it is, what am I doing wrong?
Thank you for your help.