benthris
benthris
CC#
Created by benthris on 1/2/2023 in #help
❔ 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];
}
}
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?
2 replies