From 82686fa108e064c0584236d6aa121c1d007eecfc Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Tue, 7 Feb 2017 11:37:33 +0100 Subject: Fixed back button and deleting with old index. --- EventMaker/EventMaker/App.xaml.cs | 44 ++++++---------------- EventMaker/EventMaker/Handler/EventHandler.cs | 1 + EventMaker/EventMaker/View/CreateEventPage.xaml | 8 +--- EventMaker/EventMaker/View/CreateEventPage.xaml.cs | 22 ++++++++++- 4 files changed, 34 insertions(+), 41 deletions(-) diff --git a/EventMaker/EventMaker/App.xaml.cs b/EventMaker/EventMaker/App.xaml.cs index 9dbb3d6..9e69362 100644 --- a/EventMaker/EventMaker/App.xaml.cs +++ b/EventMaker/EventMaker/App.xaml.cs @@ -41,7 +41,7 @@ namespace EventMaker ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { - titleBar.BackgroundColor = Color.FromArgb(255,16,110,190); + titleBar.BackgroundColor = Color.FromArgb(255, 16, 110, 190); titleBar.ButtonBackgroundColor = Color.FromArgb(255, 16, 110, 190); } #endif @@ -55,7 +55,6 @@ namespace EventMaker rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; - rootFrame.Navigated += OnNavigated; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) @@ -66,28 +65,18 @@ namespace EventMaker // Place the frame in the current Window Window.Current.Content = rootFrame; - // Register a handler for BackRequested events and set the - // visibility of the Back button - SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; - - SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = - rootFrame.CanGoBack ? - AppViewBackButtonVisibility.Visible : - AppViewBackButtonVisibility.Collapsed; - - } - - if (e.PrelaunchActivated == false) - { - if (rootFrame.Content == null) + if (e.PrelaunchActivated == false) { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(View.EventPage), e.Arguments); + if (rootFrame.Content == null) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame.Navigate(typeof(View.EventPage), e.Arguments); + } + // Ensure the current window is active + Window.Current.Activate(); } - // Ensure the current window is active - Window.Current.Activate(); } } @@ -125,16 +114,5 @@ namespace EventMaker deferral.Complete(); } - private void OnBackRequested(object sender, BackRequestedEventArgs e) - { - Frame rootFrame = Window.Current.Content as Frame; - - if (rootFrame.CanGoBack) - { - e.Handled = true; - rootFrame.GoBack(); - } - } - } } diff --git a/EventMaker/EventMaker/Handler/EventHandler.cs b/EventMaker/EventMaker/Handler/EventHandler.cs index ab1e2a3..448e007 100644 --- a/EventMaker/EventMaker/Handler/EventHandler.cs +++ b/EventMaker/EventMaker/Handler/EventHandler.cs @@ -26,6 +26,7 @@ namespace EventMaker.Handler public void DeleteEvent() { EventViewModel.EventCatalogSingleton.Remove(EventViewModel.EventCatalogSingleton.Events[EventViewModel.SelectedEventIndex]); + EventViewModel.SelectedEventIndex = 0; } } } diff --git a/EventMaker/EventMaker/View/CreateEventPage.xaml b/EventMaker/EventMaker/View/CreateEventPage.xaml index a4e453e..a6bf30b 100644 --- a/EventMaker/EventMaker/View/CreateEventPage.xaml +++ b/EventMaker/EventMaker/View/CreateEventPage.xaml @@ -165,13 +165,7 @@ - +