Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to trigger item change in Xamarin.Forms.InputKit inside model view

$
0
0

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;
    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>