如何在WPF应用程序中为WebView的“ ScriptNotify”添加允许的URI列表?

时间:2018-07-14 21:02:47

标签: webview windows-community-toolkit

我正在尝试使用“ window.external.notify('我的消息');”来调用C#方法。从JavaScript,似乎没有用。我的猜测是我必须在当前window.location中添加允许的域列表,但是如何在WPF应用程序中执行此操作?我在网上看到的所有内容都与UWP有关。

This is what I have:
['conference room one', ['reservation 2', 'reservation 1', 'reservation 3']]
['conference room two', ['reservation 7', 'reservation 5', 'reservation 6']]
['conference room two', ['reservation 10', 'reservation 11', 'reservation 12']]
['conference room one', ['reservation 9', 'reservation 8', 'reservation 15']]
['conference room one', ['reservation 17', 'reservation 14', 'reservation 13']]


This is what I want:
['conference room one', ['reservation 2', 'reservation 1', 'reservation 3', 'reservation 9', 'reservation 8', 'reservation 15', 'reservation 17', 'reservation 14', 'reservation 13']]
['conference room two', ['reservation 7', 'reservation 5', 'reservation 6', 'reservation 10', 'reservation 11', 'reservation 12']]

1 个答案:

答案 0 :(得分:1)

确保将IsScriptNotifyAllowedIsJavaScriptEnabled属性设置为true,则事件应触发。

编辑:3.0.0程序包中的WPF WebView中有一个错误。 issue has been opened on GitHub to resolve it

编辑2:该错误已在软件包的4.0.0版本中修复。我正在与社区合作,将修补程序移植到服务3.0.0。 PR 2346

编辑3:该错误也已在3.0服务分支中修复。将新软件包发布到NuGet时将更新

编辑4:该错误已修复,新软件包已推送到NuGet