I am involved in a project where I am stuck in the following situation: I have a picker (dropdown) where it needs to display a second picker based on first selected item from the first picker (Cascading). Values are dynamic (from Sqlite tables). Here you have my codes:
XAML
Picker 1
<Picker x:Name="picker" Title="Select Country" SelectedIndexChanged="OnModeChosen">
Picker 2
<Picker x:Name="picker2" Title="Select Regions" IsEnabled="False">
Models
public class Country
{
[PrimaryKey]
Public int CountryId {get;set;}
public string CountryName {get;set;}
public Country(){}
}
public class Regions
{
[PrimaryKey]
public int RegionsId {get; set;}
public string RegionsName {get;set;}
[ForeignKey(typeof(Country))]
public int CountryId {get;set;}
public Regions(){}
}
// Code Behind
private void OnModeChosen(object sender, EventArgs e)
{
Picker modePicker = (Picker)sender;
var mode = picker.SelectedIndex;
picker2.Items.Clear();
switch(mode)
{
//This is the part I would like dynamic
}
}
I would like the handler "OnModeChosen" to work dynamically (any selected value from picker 1 will display the according values of picker 2). By the way, I would appreciate any other approach, as I am interested in having the expected result. Thanks for your support guys. I am working on this for hours and can't find anything worth it on internet.