How to get next or previous selected item in CollectionView Grouping?

Viewed 74

I have a CollectionView with Item source and selected items bound to my view model. I am having trouble finding a way to click my next button and have the selected item in the list increment. This would not be an issue when binding to a regular collection, but when binding to a grouping object I cannot figure out how to do it.

So basically I need to figure out what the item after the selected item is in ObservableCollection<Grouping<string, QuestionBase>>(); Almost like flattening the group to see whats next.

//Where it gets bound in the view.    
     
 <CollectionView Grid.Row="0" ItemsSource="{Binding GroupedQuestions}"
                  SelectedItem="{Binding SelectedQuestion, Mode=TwoWay}"
                  IsGrouped="True" SelectionMode="Single" >
    

 
//The object used to make the grouping: 
        
      public class Grouping<K, T> : ObservableCollection<T>
        {
            public K Key { get; private set; }
        
            public Grouping(K key, IEnumerable<T> items)
            {
                Key = key;
                foreach (var item in items)
                    this.Items.Add(item);
            }
        }

//How the grouping object gets created.   
        
   GroupedQuestions = new ObservableCollection<Grouping<string, QuestionBase>>();
        GroupedQuestions.Add(new Grouping<string, QuestionBase>("Group 1", _questions));
        GroupedQuestions.Add(new Grouping<string, QuestionBase>("Group 2", _questions2));
        GroupedQuestions.Add(new Grouping<string, QuestionBase>("Group 3", _questions3));
0 Answers
Related