根据 webview 的内容更改 XAML 页面

Change the XAML Page based on the content of the webview

我有一个 Windows 10 通用应用程序 (C#),如果 webview 说要更改页面,我找不到如何更改到另一个 XAML 页面。

谢谢!

假设您控制该页面并且该页面有权发出通知(即使用 NavigateToString 或 https 从应用生成并在 ApplicationContentUriRules. See Developing secure apps), the JavaScript in your page can call window.external.notify to trigger a WebView.ScriptNotify 事件。 Xaml 页面可以订阅 ScriptNotify 并导航以响应该通知。

如果您只想在 WebView 中进行导航,您可以监听 WebView。NavigationStarting(等)事件并触发基于此的 Xaml 代码。