I am using Xamarin.Forms.InputKit drop down list for my app and I want to handle the item change triggering inside the Model View. There is a option in code behind. But I want in Model view.
XAML
<input:Dropdown Title="Chosse an option below:"
TitleColor="Black"
AnnotationColor="Accent"
IsRequired="True"
BorderColor="Black"
PropertyChanged="Dropdown_PropertyChanged"
Color="BlueViolet"
Placeholder="Choose one"
ItemsSource="{Binding MyList}"
SelectedItem="{Binding SelectedItem}" />
View Model
public IList<MonthData> MyList { get; set; } = new ObservableCollection<MonthData>();
private MonthData _selectedItem;
for (int i = 0; i < 6; i++)
{
MyList.Add(new MonthData { mId = i, mName = "Option " + (i + 1) });
}
public MonthData SelectedItem
{
get => _selectedItem;
set { _selectedItem = value; OnPropertyChanged(); }
}
MonthData class
public class MonthData
{
public int mId { get; set; }
public string mName { get; set; }
public override string ToString() => mName;
}