浏览器中打开特定网址

xaml中加入链接

 <TextBlock TextWrapping="Wrap">This is a 
                                    <Run TextDecorations="Underline">UnderlineRun>
                                    and this is a 
                                    <Hyperlink Click="Hyperlink_Click"
                                        NavigateUri="http://www.baidu.com">Hyperlink
                                    Hyperlink>
                                TextBlock>

.cs

 private void Hyperlink_Click(object sender, RoutedEventArgs e)
        {
            Hyperlink hy = (Hyperlink)sender;
             //打开特定网址:

            //浏览器中打开
            System.Diagnostics.Process.Start(hy.NavigateUri.ToString());

            //窗口中打开
            WebBrowser wb = new WebBrowser();
            wb.Source = new Uri(hy.NavigateUri.ToString()); 
            Window u = new Window();
            u.Content = wb;
            u.Show();
        }

你可能感兴趣的:(C#学习和进阶,浏览器,xaml,WPF-C#)