none
如下所示的情况如何使其跳转到HTML页面? RRS feed

  • 问题

  • 我使用VS2012编译,win8,Grid App.在我使用C#编译的其中一个页面中,有一个按钮控件,我编译了如下事件使其能够跳转到其它页面,比如跳转到另一个XAML页面,代码如下:

            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                this.Frame.Navigate(typeof(BasicPage3));
            }

    现在我在程序中插入了一个HTML页,如下图所示,请问什么命令才能使这个按钮控件点击后由C#跳转到这个HTML页并显示出HTML上的信息?求解答。求正确代码,谢谢!!!

    2014年2月8日 15:10

答案

  • Hi,

    你这个的话应该要在xaml页面定义一个WebView 控件,然后由WebView 控件来显示HTMLPage里面的内容:

     <WebView x:Name="webview" HorizontalAlignment="Left" Height="379" Margin="276,94,0,0" VerticalAlignment="Top" Width="645"/>
    Windows.Storage.StorageFile MyWebPageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///HTMLPage1.html"));
                string MyWebPageString = await FileIO.ReadTextAsync(MyWebPageFile);
     webview.NavigateToString(MyWebPageString);

    具体请看Ten Things You Need to Know About WebView

    祝您好运!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • 已标记为答案 (C)sharp.sq 2014年2月17日 11:41
    2014年2月10日 6:14
    版主