how to filter list using linq windows phone ListPicker
I have List< Parameter > = App.ViewModel.Items where Parameter has a
string Category. In the List, there are 30 Parameters with 4 distinct
Category (Head, Neck, Ears and Throat). The list populates the
MainLongListSelector on the main page.
I have a _categorySelector (ListPicker) populated using :
_categorySelector.ItemsSource = App.ViewModel.Items.Select(m =>
m.Category).Distinct().ToList();
On the SelectionChanged event handler, I want to filter to
MainLongListSelector with the selected value of the ListPicker.
I have this so far, that doesn't work:
private void _categorySelector_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
var query = (from jj in App.ViewModel.Items
where (_categorySelector.SelectedItem as
Parameter).Category == jj.Category
select jj).ToList(); //doesn't work
var qq = App.ViewModel.Items.Select(mm => mm.Category).Distinct();
//doesn't connect selected item content to query
MainLongListSelector.ItemsSource = query;
}
No comments:
Post a Comment