protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { PanoramaItem panoramaItem = Panorama.SelectedItem as PanoramaItem; if(panoramaItem.Name == "UserPanorama") { //if back button is pressed and the screen isnt showing the profile grid //then that means we are viewing another grid. so close all other grids //and show the user profile grid if (userProfileGrid.Visibility == System.Windows.Visibility.Collapsed && loggedIn == true && showFriendProfileGrid.Visibility == System.Windows.Visibility.Collapsed) { userProfileGrid.Visibility = System.Windows.Visibility.Visible; CheckInGrid.Visibility = System.Windows.Visibility.Collapsed; friendShowGrid.Visibility = System.Windows.Visibility.Collapsed; showTipGrid.Visibility = System.Windows.Visibility.Collapsed; showMayorGrid.Visibility = System.Windows.Visibility.Collapsed; showFriendProfileGrid.Visibility = System.Windows.Visibility.Collapsed; //e.cancel stops app frem going back or backing out e.Cancel = true; } //if the friend profile is currently visible else if(showFriendProfileGrid.Visibility == System.Windows.Visibility.Visible) { //close the friend profile view and show the list of all your friends showFriendProfileGrid.Visibility = System.Windows.Visibility.Collapsed; friendShowGrid.Visibility = System.Windows.Visibility.Visible; e.Cancel = true; } } else if(panoramaItem.Name == "ActivityPanorama") { //if back button pressed and activity isnt visible then make it visible. but if the back button is pressed //and activityfeedgrid is visible then exit the app. if (ActivityFeedGrid.Visibility == System.Windows.Visibility.Collapsed && loggedIn == true) { //set venueviewmode to null so we can reclaim the memory venueViewModel = null; ActivityFeedGrid.Visibility = System.Windows.Visibility.Visible; venuePageGrid.Visibility = System.Windows.Visibility.Collapsed; ActivitySignInGrid.Visibility = System.Windows.Visibility.Collapsed; e.Cancel = true; } } }
private void ActivityFeedLongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (ActivityFeedLongListSelector.SelectedItem == null) return; //get the selected item var selectedItem = ActivityFeedLongListSelector.SelectedItem as ActivityItem; venueViewModel = new VenueViewModel(locationMap); //set data context of venue venuePageGrid.DataContext = venueViewModel; //load venue venueViewModel.loadVenueData(venuePageGrid, ActivityProgressBar, selectedItem.venueId); //close current grid ActivityFeedGrid.Visibility = System.Windows.Visibility.Collapsed; //make progress bar visible ActivityProgressBar.IsEnabled = true; ActivityProgressBar.Visibility = System.Windows.Visibility.Visible; ActivityFeedLongListSelector.SelectedItem = null; }