Example #1
0
        /// <summary>
        /// Called when Source property is changed
        /// </summary>
        /// <param name="depObj">The dependency property</param>
        /// <param name="e">The event arguments</param>
        private static void SourcePropertyChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e)
        {
            Frame frame = depObj as Frame;

            // Verify frame reference is valid and we're not in design mode.
            if (frame != null &&
                !Frame.IsInDesignMode() &&
                frame._loaded &&
                frame._updatingSourceFromNavigationService == false)
            {
                frame.Navigate(e.NewValue as Uri);
            }

            if (Frame.IsInDesignMode())
            {
                if (e.NewValue != null)
                {
                    frame.Content = String.Format(CultureInfo.InvariantCulture, Resource.Frame_DefaultContent, e.NewValue.ToString());
                }
                else
                {
                    frame.Content = frame.GetType().Name;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Called when the Frame.Loaded event fires.
        /// </summary>
        /// <param name="sender">The object raising the event</param>
        /// <param name="e">The event arguments</param>
        private void Frame_Loaded(object sender, RoutedEventArgs e)
        {
            this._navigationService.InitializeJournal();

            if (this.ContentLoader == null)
            {
                this.ContentLoader = new PageResourceContentLoader();
            }

            this._navigationService.InitializeNavigationCache();

            // Set loaded flag
            this._loaded = true;

            // Don't attempt to load anything at design-time
            if (!Frame.IsInDesignMode())
            {
                UriMapperBase mapper = this.UriMapper;

                // If there's a deeplink, don't check Source as the deeplink overrides it
                if (this.ApplyDeepLinks() == false)
                {
                    if (this._deferredNavigation != null)
                    {
                        this.Navigate(this._deferredNavigation);
                        this._deferredNavigation = null;
                    }

                    // Check if source property was set
                    else if (this.Source != null)
                    {
                        this.Navigate(this.Source);
                    }

                    // If no Source was set, we may still be able to use UriMapper to convert this to a navigable Uri
                    else if (mapper != null)
                    {
                        Uri emptyUri  = new Uri(String.Empty, UriKind.Relative);
                        Uri mappedUri = mapper.MapUri(emptyUri);
                        if (mappedUri != null && !String.IsNullOrEmpty(mappedUri.OriginalString))
                        {
                            this.Navigate(emptyUri);
                        }
                    }
                }
            }
            else
            {
                if (this.Source != null)
                {
                    this.Content = String.Format(CultureInfo.InvariantCulture, Resource.Frame_DefaultContent, this.Source.ToString());
                }
                else
                {
                    this.Content = typeof(Frame).Name;
                }
            }
        }