示例#1
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Notes.Clear();
                var notes = await NoteDataStore.GetNotesAsync();

                foreach (var note in notes)
                {
                    Notes.Add(note);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#2
0
        public ItemsViewModel()
        {
            Title            = "NoteKeeper";
            Notes            = new ObservableCollection <Note>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <ItemDetailPage, Note>(this, "SaveNote",
                                                             async(sender, note) =>
            {
                Notes.Add(note);
                await NoteDataStore.AddNoteAsync(note);
            }
                                                             );

            MessagingCenter.Subscribe <ItemDetailPage, Note>(this, "UpdateNote",
                                                             async(sender, note) =>
            {
                await NoteDataStore.UpdateNoteAsync(note);

                await ExecuteLoadItemsCommand();
            }
                                                             );
        }
示例#3
0
 async void InitializeCourseList()
 {
     CourseList = await NoteDataStore.GetCoursesAsync();
 }