C
C#2w ago
Mustafa

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.
No description
No description
No description
No description
3 Replies
Casianm8
Casianm82w ago
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.
// When you create the attributes, try to make them all according to this model (search the internet why)

private int? _category_Id;
public int? CategoryId
{
get { return _category_Id; }
set { _category_Id = value;
OnPropertyChanged();
}
}

// and here u can delete:
[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].
// When you create the attributes, try to make them all according to this model (search the internet why)

private int? _category_Id;
public int? CategoryId
{
get { return _category_Id; }
set { _category_Id = value;
OnPropertyChanged();
}
}

// and here u can delete:
[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].
// and add on every list like this

private List<Category> _SubChild_categories = new List<Category>();
public List<Category> SubChild_Categories
{
get { return _SubChild_categories; }
set { _SubChild_categories = value;
OnPropertyChanged();
}
}

private List<Category> _child_categories = new List<Category>();
public List<Category> Child_Categories
{
get { return _child_categories; }
set { _child_categories = value;
OnPropertyChanged();
}
}
// and add on every list like this

private List<Category> _SubChild_categories = new List<Category>();
public List<Category> SubChild_Categories
{
get { return _SubChild_categories; }
set { _SubChild_categories = value;
OnPropertyChanged();
}
}

private List<Category> _child_categories = new List<Category>();
public List<Category> Child_Categories
{
get { return _child_categories; }
set { _child_categories = value;
OnPropertyChanged();
}
}
->> So that the lists are updated every time.
Casianm8
Casianm82w ago
Here is corrected code:
Want results from more Discord servers?
Add your server