public object Execute()

in src/BehaviorsSDKManaged/Microsoft.Xaml.Interactions/Core/NavigateToPageAction.cs [94:145]


        public object Execute(object sender, object parameter)
        {
            if (string.IsNullOrEmpty(this.TargetPage))
            {
                return false;
            }

            IXamlMetadataProvider metadataProvider = Application.Current as IXamlMetadataProvider;
            if (metadataProvider == null)
            {
                // This will happen if there are no XAML files in the project other than App.xaml.
                // The markup compiler doesn't bother implementing IXamlMetadataProvider on the app
                // in that case.
                return false;
            }

            IXamlType xamlType = metadataProvider.GetXamlType(this.TargetPage);
            if (xamlType == null)
            {
                return false;
            }

            INavigate navigateElement = Window.Current.Content as INavigate;
            DependencyObject senderObject = sender as DependencyObject;

            // If the sender wasn't an INavigate, then keep looking up the tree from the
            // root we were given for another INavigate.
            while (senderObject != null && navigateElement == null)
            {
                navigateElement = senderObject as INavigate;
                if (navigateElement == null)
                {
                    senderObject = this._visualTreeHelper.GetParent(senderObject);
                }
            }

            if (navigateElement == null)
            {
                return false;
            }

            Frame frame = navigateElement as Frame;

            if (frame != null)
            {
                return frame.Navigate(xamlType.UnderlyingType, this.Parameter ?? parameter);
            }
            else
            {
                return navigateElement.Navigate(xamlType.UnderlyingType);
            }
        }