private async void OnCategorySelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem is DreamCategoryViewModel model) { DreamCategoryEditorViewModel editorModel = new DreamCategoryEditorViewModel(); editorModel.Update(model); await this.Navigation.PushModalAsync(new NavigationPage(new CreateEditDreamCategoryPage(editorModel))); this.categoriesListView.SelectedItem = null; } }
public CreateEditDreamCategoryPage(DreamCategoryEditorViewModel category) { this.AvailableColors = this.GetAvailableColors(); this.Title = "Edit dream category"; this.Category = category; this.IsEdit = true; var test1 = ((System.Drawing.Color) this.Category.Color).ToArgb(); var test2 = this.AvailableColors.Select(_color => ((System.Drawing.Color)_color.Color).ToArgb()).OrderBy(_color => _color); var test = this.AvailableColors.FirstOrDefault(_color => ((System.Drawing.Color)_color.Color).ToArgb() == ((System.Drawing.Color) this.Category.Color).ToArgb()); this.Category.SelectedColor = this.AvailableColors.FirstOrDefault(_color => _color.Color.Equals(this.Category.Color)); this.InitializeComponent(); this.BindingContext = this; }