C# 从html页面导航到windows 8 xaml页面

C# 从html页面导航到windows 8 xaml页面,c#,windows-8,webview,C#,Windows 8,Webview,序言: 我有一个c#/xaml项目。在这个项目中,我有两个页面(MainPage.xaml和SecondExamplePage),MainPage上有MainWebView。在mainPage.xaml.cs上,我有一个简单的代码: protected override void OnNavigatedTo(NavigationEventArgs e) { MainWebView.Source = new Uri("ms-appx-web:///assets/physi

序言: 我有一个c#/xaml项目。在这个项目中,我有两个页面(MainPage.xaml和SecondExamplePage),MainPage上有MainWebView。在mainPage.xaml.cs上,我有一个简单的代码:

 protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        MainWebView.Source = new Uri("ms-appx-web:///assets/physics/index.html");
    }
当用户启动应用程序时,他会看到html页面(index.html),例如,只有一张图片,就这样。(我现在知道,这是错误的方式,但客户希望这样)


我需要做的事情:当用户单击image(在index.html页面上)时,我需要在SecondExamplePage.xaml上导航,我该怎么做?我了解了WebView.ScriptNotify和WebView.InvokeScript,但我不明白这个方法是如何工作的。

在html页面中,图像标记看起来像这样:

<img src="./image.png" onclick="external.notify('gotoPage2')" />

该示例在这方面也可能对您有所帮助。

我们如何将一些参数从html页面(例如html页码)发送到第2页?您可以使用一个字符串,这样您就可以在其中抛出您想要的任何内容,并在另一侧进行解析。也许是URL查询字符串格式的东西?
    public MainPage()
    {
        this.InitializeComponent();
        MainWebView.ScriptNotify += WebView_ScriptNotify;
    }

    void MainWebView_ScriptNotify(object sender, NotifyEventArgs e)
    {
        if (e.Value == "gotoPage2")
            this.Frame.Navigate(typeof(Page2));
    }