예제 #1
0
        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;
            });
        }
예제 #2
0
        public DetailPage(DetailPageViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = viewModel;
        }