Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to update item inside ObservableCollection

$
0
0

Hi all i have an ObservableCollection of model i want to change an item inside

public class MainModel
    {
        public int id { get; set; }
        public string name { get; set; }
        public string mainImage { get; set; }
        public Xamarin.Forms.Color textColor { get; set; }
    }

 public event PropertyChangedEventHandler PropertyChanged;

        public ObservableCollection<MainModel> _themes;

        public ObservableCollection<MainModel> themes
        {
            get { return _themes; }
            set
            {
                _themes = value;
                OnPropertyChanged("themes");
            }
        }

public ICommand changeColor
        {
            get
            {
                return new Command(() =>
                {
                    for(int i = 0; i < themes.Count; i++)
                    {
                        if (themes[i].id == Settings.categoryID)
                        {
                            themes[i].textColor = Xamarin.Forms.Color.FromHex("#eb1f8e");
                        }
                    }
                });
            }
        }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



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