C#C
C#3y ago
benthris

❔ How do I cycle through different observable collections within the same collection view?

My current plan is to do something like:
      List <ObservableCollection<TodoItem>> allTodoItemsLists= new List <ObservableCollection<TodoItem>>();
        private ObservableCollection<TodoItem> selectedtodoItems;
        public ObservableCollection<TodoItem> SelectedTodoItems { get => selectedtodoItems;
            set { selectedtodoItems = value; 
                OnPropertyChanged();
                }
            }

        int currentListIndex;
        public int CurrentListIndex { get => currentListIndex; set{
                currentListIndex=value;
                SelectedTodoItems = allTodoItemsLists[currentListIndex];
                }
            }

Using SelectedTodoItems as the ItemSource binding within the collection view.
But this seems too inelegant. Is there a better way of doing this?
Was this page helpful?