Inheritance: Windows.UI.Xaml.Controls.ContentControl
 public AppShell(LaunchActivatedEventArgs e)
 {
     this.InitializeComponent();
     Frame = this.RootFrame;
     Frame.Navigate(typeof(MainPage), e);
     //DC.ShowVisualTree();
     DC.Hide();
 }
        /// <summary>
        /// Handles changes to the Frame property.
        /// </summary>
        /// <param name="d">
        /// The <see cref="DependencyObject"/> on which
        /// the property has changed value.
        /// </param>
        /// <param name="e">
        /// Event data that is issued by any event that
        /// tracks changes to the effective value of this property.
        /// </param>
        private static void OnFrameChanged(
            DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var target = (AlternativePage)d;
            AlternativeFrame oldFrame = (AlternativeFrame)e.OldValue;
            AlternativeFrame newFrame = target.Frame;

            target.OnFrameChanged(oldFrame, newFrame);
        }
        public AppShell(FileActivatedEventArgs e)
        {
            this.InitializeComponent();
            Frame = this.RootFrame;
            Frame.Navigate(typeof(MainPage), e);
#pragma warning disable 4014
            this.HandleFileActivationAsync(e);
#pragma warning restore 4014
        }
        private void InitializeFrame(object args)
        {
            Frame = this.RootFrame;
            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
            coreTitleBar.ExtendViewIntoTitleBar = true;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            Frame.NavigateAsync(typeof(MainPage), args);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
            Frame.Navigated += async (s, e) =>
            {
                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = Frame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed;
                WindowTitleBar.Instance.IsBackButtonVisible = Frame.CanGoBack;
            };
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
            SystemNavigationManager.GetForCurrentView().BackRequested += async (s, e) => await Frame.GoBackAsync();
            WindowTitleBar.Instance.BackButtonClicked += async (s, e) => await Frame.GoBackAsync();
        }
 /// <summary>
 /// Provides derived classes an opportunity to handle changes
 /// to the Frame property.
 /// </summary>
 /// <param name="oldFrame">The old Frame value</param>
 /// <param name="newFrame">The new Frame value</param>
 protected virtual void OnFrameChanged(
     AlternativeFrame oldFrame, AlternativeFrame newFrame)
 {
 }
 public AppShell()
 {
     this.InitializeComponent();
     Frame = this.RootFrame;
     this.RootFrame.Navigate(typeof (MainPage));
 }
 private static void SaveFrameNavigationState(AlternativeFrame frame)
 {
     var frameState = SessionStateForFrame(frame);
     frameState["Navigation"] = frame.GetNavigationState();
 }
 private static void RestoreFrameNavigationState(AlternativeFrame frame)
 {
     var frameState = SessionStateForFrame(frame);
     if (frameState.ContainsKey("Navigation"))
     {
         frame.SetNavigationState((String)frameState["Navigation"]);
     }
 }
        /// <summary>
        /// Provides storage for session state associated with the specified <see cref="AlternativeFrame"/>.
        /// Frames that have been previously registered with <see cref="RegisterFrame"/> have
        /// their session state saved and restored automatically as a part of the global
        /// <see cref="SessionState"/>.  Frames that are not registered have transient state
        /// that can still be useful when restoring pages that have been discarded from the
        /// navigation cache.
        /// </summary>
        /// <remarks>Apps may choose to rely on <see cref="LayoutAwarePage"/> to manage
        /// page-specific state instead of working with frame session state directly.</remarks>
        /// <param name="frame">The instance for which session state is desired.</param>
        /// <returns>A collection of state subject to the same serialization mechanism as
        /// <see cref="SessionState"/>.</returns>
        public static Dictionary<String, Object> SessionStateForFrame(AlternativeFrame frame)
        {
            var frameState = (Dictionary<String, Object>)frame.GetValue(FrameSessionStateProperty);

            if (frameState == null)
            {
                var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
                if (frameSessionKey != null)
                {
                    // Registered frames reflect the corresponding session state
                    if (!_sessionState.ContainsKey(frameSessionKey))
                    {
                        _sessionState[frameSessionKey] = new Dictionary<String, Object>();
                    }
                    frameState = (Dictionary<String, Object>)_sessionState[frameSessionKey];
                }
                else
                {
                    // Frames that aren't registered have transient state
                    frameState = new Dictionary<String, Object>();
                }
                frame.SetValue(FrameSessionStateProperty, frameState);
            }
            return frameState;
        }
 /// <summary>
 /// Disassociates a <see cref="AlternativeFrame"/> previously registered by <see cref="RegisterFrame"/>
 /// from <see cref="SessionState"/>.  Any navigation state previously captured will be
 /// removed.
 /// </summary>
 /// <param name="frame">An instance whose navigation history should no longer be
 /// managed.</param>
 public static void UnregisterFrame(AlternativeFrame frame)
 {
     // Remove session state and remove the frame from the list of frames whose navigation
     // state will be saved (along with any weak references that are no longer reachable)
     SessionState.Remove((String)frame.GetValue(FrameSessionStateKeyProperty));
     _registeredFrames.RemoveAll((weakFrameReference) =>
     {
         AlternativeFrame testFrame;
         return !weakFrameReference.TryGetTarget(out testFrame) || testFrame == frame;
     });
 }
        /// <summary>
        /// Registers a <see cref="AlternativeFrame"/> instance to allow its navigation history to be saved to
        /// and restored from <see cref="SessionState"/>.  Frames should be registered once
        /// immediately after creation if they will participate in session state management.  Upon
        /// registration if state has already been restored for the specified key
        /// the navigation history will immediately be restored.  Subsequent invocations of
        /// <see cref="RestoreAsync"/> will also restore navigation history.
        /// </summary>
        /// <param name="frame">An instance whose navigation history should be managed by
        /// <see cref="SuspensionManager"/></param>
        /// <param name="sessionStateKey">A unique key into <see cref="SessionState"/> used to
        /// store navigation-related information.</param>
        public static void RegisterFrame(AlternativeFrame frame, String sessionStateKey)
        {
            if (frame.GetValue(FrameSessionStateKeyProperty) != null)
            {
                throw new InvalidOperationException("Frames can only be registered to one session state key");
            }

            if (frame.GetValue(FrameSessionStateProperty) != null)
            {
                throw new InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all");
            }

            // Use a dependency property to associate the session key with a frame, and keep a list of frames whose
            // navigation state should be managed
            frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey);
            _registeredFrames.Add(new WeakReference<AlternativeFrame>(frame));

            // Check to see if navigation state can be restored
            RestoreFrameNavigationState(frame);
        }
Esempio n. 12
0
 /// <summary>
 /// Provides derived classes an opportunity to handle changes
 /// to the Frame property.
 /// </summary>
 /// <param name="oldFrame">The old Frame value</param>
 /// <param name="newFrame">The new Frame value</param>
 protected virtual void OnFrameChanged(
     AlternativeFrame oldFrame, AlternativeFrame newFrame)
 {
 }