C# 如何在通用windows应用程序中更新webview页面控件值
我正在开发一个运行在Windows8.1和WindowsPhone8.1上的通用应用程序。在旧的基于Silverlight的Windows Phone应用程序中,我可以在WebView页面中插入javascript 我的Silverlight(windows 8.0)代码如下:C# 如何在通用windows应用程序中更新webview页面控件值,c#,wpf,windows-10-universal,C#,Wpf,Windows 10 Universal,我正在开发一个运行在Windows8.1和WindowsPhone8.1上的通用应用程序。在旧的基于Silverlight的Windows Phone应用程序中,我可以在WebView页面中插入javascript 我的Silverlight(windows 8.0)代码如下: Dispatcher.BeginInvoke(() => { Browser.InvokeScript("eval", "document.getElementById('lblLocation').inn
Dispatcher.BeginInvoke(() =>
{
Browser.InvokeScript("eval", "document.getElementById('lblLocation').innerHTML=['" + address + "']");
Browser.InvokeScript("eval", "document.getElementById('ConsumerServiceAndPeriod_TimeOutLong').value='" + _longitute + "'");
});
现在我正在尝试创建具有相同功能的通用应用程序,如
private void doOperation(Coordinates objCoordinates)
{
var dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
var ignored = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Browser.InvokeScript("eval", new string[] { "document.getElementById('lblLocation').innerHTML=['" + _address + "']" });
});
}
执行之后,我犯了一个错误,
未实现该方法或操作
有人知道这个功能吗?根据我的快速研究,Windows 8.1中似乎不推荐使用
InvokeScript
方法(请参阅中的备注,查看注释下的早期版本)。相反,您应该使用InvokeScriptAsync
此外,您可能还想查看-it's HTML示例,谢谢您的快速回复。我得到了答案。var ignored=dispatcher.RunAsync(CoreDispatcherPriority.Normal,async()=>{Browser.InvokeScript(“eval”,新字符串[]{”document.getElementById('lblLocation')。innerHTML=[''+\u address+“]”});})