コード例 #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            recipes                    = (RecipeList)e.Parameter;
            selectedRecipe             = recipes.getSelected();
            detailSection.SelectedItem = detailSection.MenuItems[0];
            contentFrame.Navigate(typeof(DetailPage), selectedRecipe);
            if (isNarrow())
            {
                IList <PageStackEntry> backStack = Frame.BackStack;
                int backStackCount = backStack.Count;
                if (backStackCount > 0)
                {
                    PageStackEntry masterPageEntry = backStack[backStackCount - 1];
                    backStack.RemoveAt(backStackCount - 1);

                    PageStackEntry modifiedEntry = new PageStackEntry(
                        masterPageEntry.SourcePageType,
                        recipes,
                        masterPageEntry.NavigationTransitionInfo
                        );

                    backStack.Add(modifiedEntry);
                }

                // Show back button
                NavigationView currShell = AppShell.currentShell;
                currShell.IsBackButtonVisible = NavigationViewBackButtonVisible.Visible;
                currShell.IsBackEnabled       = true;
            }
        }
コード例 #2
0
        private async void tryDeleteRecipe(Recipe recipeToDelete)
        {
            ContentDialog deleteConfirmationDialog = new ContentDialog
            {
                Title   = "Permenantly delete recipe?",
                Content = "If you delete this recipe, you won't be" +
                          " able to recover it. Are you Sure you want to delete" +
                          " it?",
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };

            ContentDialogResult result = await deleteConfirmationDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                int deleteIndex = recipes.getRecipeList().IndexOf(recipeToDelete);

                if (deleteIndex > 0)
                {
                    // deleting recipe somewhere other than beginning
                    // select the recipe before it
                    recipes.SelectedIndex = deleteIndex - 1;
                }
                else if (deleteIndex == 0)
                {
                    // deleting recipe at the beginning
                    // select the same index
                    recipes.SelectedIndex = 0;
                }

                recipes.removeRecipe(recipeToDelete);
                if (isNarrow())
                {
                    Frame.GoBack();
                }
                else
                {
                    if (recipes.Recipes.Count == 0)
                    {
                        // hide this column
                        detailSectionGrid.Visibility = Visibility.Collapsed;
                    }
                    selectedRecipe             = recipes.getSelected();
                    detailSection.SelectedItem = detailSection.MenuItems[0];
                    contentFrame.Navigate(typeof(DetailPage), selectedRecipe);
                }
            }
        }