Ejemplo n.º 1
0
        protected override async void OnNavigatedTo(NavigationEventArgs obj)
        {
            base.OnNavigatedTo(obj);
            rootPage = ((App)Application.Current).CurrentMain;
            if (obj.Parameter != null)
            {
                rootPage.UpdateTitle(ThoughtRecordListModel.Title);
                int thoughtRecordId = Convert.ToInt32(obj.Parameter);
                ViewModel = new ThoughtRecordDisplayModel(AppDataService.GetDatabase(Application.Current));
                await ViewModel.InitializeModel(thoughtRecordId);

                if (ViewModel.ThoughtRecord == null)
                {
                    NavigateWithBackStackRemoval(typeof(ThoughtRecordListPage));
                }
                else
                {
                    ViewModel.OnThoughtRecordDeleteRequested += ConfirmDeleteRequest;
                    ViewModel.OnThoughtRecordDeleted         += NavigatetoListPageAfterDelete;
                    ViewModel.OnThoughtRecordEditRequested   += NavigateToEditPage;
                    ViewModel.OnThoughtRecordChanged         += ScrollToTop;
                    rootPage.UpdateTitle(ThoughtRecordDisplayModel.Title);
                    rootPage.NavigateWithMenuUpdate(typeof(ThoughtRecordDisplayPage), thoughtRecordId);
                }
            }
            else
            {
                NavigateWithBackStackRemoval(typeof(ThoughtRecordListPage));
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage  = ((App)(Application.Current)).CurrentMain;
            ViewModel = new ThoughtRecordListModel(AppDataService.GetDatabase(Application.Current));
            rootPage.UpdateTitle(ThoughtRecordListModel.Title);
            rootPage.NavigateWithMenuUpdate(this.GetType());
            await InitializeViewModel();

            base.OnNavigatedTo(e);
        }
        protected override void OnNavigatedTo(NavigationEventArgs obj)
        {
            rootPage = (Application.Current as App).CurrentMain;
            int thoughtRecordId = Convert.ToInt32(obj.Parameter);

            if (thoughtRecordId != 0)
            {
                ViewModel = new ThoughtRecordEditModel(thoughtRecordId, AppDataService.GetDatabase(Application.Current));
            }
            else
            {
                ViewModel = new ThoughtRecordEditModel(AppDataService.GetDatabase(Application.Current));
            }
            rootPage.UpdateTitle(ViewModel.Title);
            ViewModel.OnThoughtRecordSaving           += ShowProgressRing;
            ViewModel.OnThoughtRecordSaved            += HideProgressRing;
            ViewModel.OnNewThoughtRecordOverwriteRisk += PromptToSave;
            ViewModel.OnNewThoughtRecordCreated       += UpdateMainMenu;
            this.Unloaded += ThoughtRecordEditPage_Unloaded;
            rootPage.NavigateWithMenuUpdate(this.GetType(), thoughtRecordId);
            base.OnNavigatedTo(obj);
        }