예제 #1
0
        public override void OnNavigatedTo(NavigationEventArgs e, bool setStatusBar = true)
        {
#if WINDOWS_PHONE_APP
            if (setStatusBar)
            {
                SetStatusBarColor((FrameworkElement)e.Content);
            }
#endif

            if (e.NavigationMode == NavigationMode.New)
            {
                PageStateStack.Push(this.State);
                if (InitializeState != null)
                {
                    InitializeState(e.Parameter);
                }
            }
            else if (e.NavigationMode == NavigationMode.Back)
            {
                var currentState = PageStateStack.Top();
                if (State.PageType != currentState.PageType)
                {
                    throw new InvalidOperationException();
                }

                if (currentState != this.State)
                {
                    this.state = currentState;
                    State.UpdateTasks(this.Page);
                    PageStateStack.Pop();
                    PageStateStack.Push(State);
                    if (RestoreState != null)
                    {
                        RestoreState(State.StateObject);
                    }
                }
                State.ResumeTasks();
            }
            else
            {
                throw new NotImplementedException("Not allowed navigation mode:" + e.NavigationMode);
            }
        }
예제 #2
0
 public static void Push(PageState state)
 {
     BackStack.Add(state);
 }