public MainPageViewModel() { Notes = new ObservableCollection <NoteModel>(); SaveNoteCommand = new Command(() => { Notes.Add(new NoteModel { Text = NoteText }); NoteText = string.Empty; }, () => !string.IsNullOrEmpty(NoteText)); EraseNotesCommand = new Command(() => Notes.Clear()); NoteSelectedCommand = new Command(async() => { if (SelectedNote is null) { return; } var detailViewModel = new DetailPageViewModel { NoteText = SelectedNote.Text }; await Application.Current.MainPage.Navigation.PushAsync(new DetailPage(detailViewModel)); SelectedNote = null; }); }
public DetailPage(DetailPageViewModel viewModel) { InitializeComponent(); BindingContext = viewModel; }