When I select a category from a picker, I want only its children to appear in the other picker
I have 3 pickers and in these pickers I have parent, child and subchild categories respectively. When I select the parent category, I want only the children of that parent to appear in the other picker as an option.However, when I select the parent category, the second picker appears empty. When I remove the Parent Category, my normal child categories appear.
3 Replies
Guide:
1. We will use the "Category.cs" class as a model... and the "CategoryViewModel" class as a viewmodel.
- Each attribute in Category.cs must have OnPropertyChanged() to perceive the new values.
- You can delete from Category.cs what is (Virtual): It is used to overwrite a method from one class to another (override) and it is not the case for you (search the internet for what it is used for). Look to see what polymorphism means or what it is used for on chatgpt.
- Check if the list is initialized in the constructor of the class in which you have the two filter methods.
- When you want to use the Selected... attribute from the ViewModel, it would be advisable to delete the .Clear property at the time of filtering.
->> So that the lists are updated every time.
Here is corrected code: