繁体   English   中英

在web浏览器控件中从Silverlight调用WPF中的函数

[英]Calling function in WPF from silverlight inside web browser control

我有一个带有Web浏览器控件的WPF应用程序,其中包含一个silveriight应用程序。 之前,我已经能够使用HTML桥从WPF应用程序调用函数到sliverlight应用程序。

现在,我必须做相反的事情,即我必须在Silverlight中调用WPF应用程序中的函数。
如何才能做到这一点?

您可以使用如下所示的属性执行此操作:

C#部分:

webBrowserControlName.ObjectForScripting = new ScriptInterface();

ScriptInterface的位置如下

[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public class ScriptInterface
{

    public void CSharpMethod(string data)
    {
        MessageBox.Show(data);
    }
}

HTML部分

在您在Web浏览器控件中加载的页面中执行以下操作:

window.External.CSharpMethod('from html page to WPF');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM