public bool GoBack() { if (backstack.Count == 0) { return(false); } if (backstack.Count == 1) { if (AdaptiveStates.CurrentState == NarrowState) { BindableMargin margin = new BindableMargin(DetailContentPresenter) { Top = 0 - LayoutRoot.ActualHeight }; DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames() { EnableDependentAnimation = true }; EasingDoubleKeyFrame f1 = new EasingDoubleKeyFrame() { Value = 0 - LayoutRoot.ActualHeight, KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.1)) }; animation.KeyFrames.Add(f1); EasingDoubleKeyFrame f2 = new EasingDoubleKeyFrame() { EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseInOut, Power = 4 }, KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.4)), Value = 0 }; animation.KeyFrames.Add(f2); Storyboard.SetTarget(animation, margin); Storyboard.SetTargetProperty(animation, "Top"); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(animation); storyboard.Completed += delegate { backstack.Clear(); DetailContentPresenter.Content = null; isBlank = true; margin.Top = 0; }; storyboard.Begin(); } else { backstack.Clear(); DetailContentPresenter.Navigate(typeof(BlankPage)); isBlank = true; } MasterListView.SelectedItem = null; return(true); } else if (backstack.Count > 1) { MasterListView.SelectedIndex = backstack[backstack.Count - 1].selectedindex; backstack.RemoveAt(backstack.Count - 1); DetailContentPresenter.Navigate(backstack[backstack.Count - 1].sender, backstack[backstack.Count - 1].e); return(true); } return(false); }
public void MasterListView_ItemClick(Type sender, object e) { _lastSelectedItem = e; DetailContentPresenter.Navigate(sender, e); backitem tmpitem = new Pages.MasterDetailControl.backitem() { sender = sender, e = e, selectedindex = MasterListView.SelectedIndex }; backstack.Add(tmpitem); isBlank = false; if (AdaptiveStates.CurrentState == NarrowState) { // Use "drill in" transition for navigating from master list to detail view //Frame.Navigate(typeof(DetailPage.WorkDetailPage), clickedItem, new DrillInNavigationTransitionInfo()); Grid.SetColumn(DetailContentPresenter, 0); Grid.SetRow(DetailContentPresenter, 1); DetailContentPresenter.BorderThickness = new Windows.UI.Xaml.Thickness(0, 0, 0, 0); BindableMargin margin = new BindableMargin(DetailContentPresenter) { Top = 0 }; DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames() { EnableDependentAnimation = true }; EasingDoubleKeyFrame f1 = new EasingDoubleKeyFrame() { Value = 0, KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.2)) }; animation.KeyFrames.Add(f1); EasingDoubleKeyFrame f2 = new EasingDoubleKeyFrame() { EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseInOut, Power = 4 }, KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.6)), Value = 0 - LayoutRoot.ActualHeight }; animation.KeyFrames.Add(f2); Storyboard.SetTarget(animation, margin); Storyboard.SetTargetProperty(animation, "Top"); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(animation); storyboard.Completed += delegate { margin.Top = 0 - LayoutRoot.ActualHeight; }; storyboard.Begin(); } else { Grid.SetColumn(DetailContentPresenter, 1); Grid.SetRow(DetailContentPresenter, 0); DetailContentPresenter.BorderThickness = new Windows.UI.Xaml.Thickness(1, 0, 0, 0); // Play a refresh animation when the user switches detail items. EnableContentTransitions(); } }