コード例 #1
0
        /// <summary>
        /// Url地址导航
        /// Browser模式下,开启新的浏览器Tab打开页面; OOB模式下,开启IE浏览器打开页面;
        /// </summary>
        /// <param name="url"></param>
        /// <param name="options"></param>
        public static void OpenPage(string url, WindowOptions options)
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (Application.Current.IsRunningOutOfBrowser)
                {
                    var uri = new Uri(url, UriKind.RelativeOrAbsolute);

                    if (!uri.IsAbsoluteUri)
                    {
                        uri = new Uri(new Uri(CPApplication.Current.PortalBaseAddress, UriKind.RelativeOrAbsolute), new Uri(url, UriKind.RelativeOrAbsolute));
                    }

                    HyperlinkOperation.OpenWebPage(uri, "_blank");
                }
                else if (!System.Windows.Application.Current.IsRunningOutOfBrowser)
                {
                    if (options != null)
                    {
                        var opt = GenerateOptions(options);
                        HtmlPage.Window.Navigate(new Uri(url, UriKind.RelativeOrAbsolute), "_blank", opt);
                    }
                    else
                    {
                        HtmlPage.Window.Navigate(new Uri(url, UriKind.RelativeOrAbsolute), "_blank");
                    }
                }
                else
                {
                    throw new InvalidOperationException();
                }
            });
        }
コード例 #2
0
        public static void OpenWebPage(Uri uri, string targetName)
        {
            HyperlinkOperation btn = new HyperlinkOperation();

            btn.NavigateUri = uri;
            btn.TargetName  = targetName;
            btn.DoClick();
        }