WPFとjsが交互にフォームを呼び出す方法
2177 ワード
public partial class WebTest: Window
{
private void Window_ContentRendered(object sender, EventArgs e)
{
this.wbrExam.ObjectForScripting = new OprateBasic(this);
this.wbrExam.Source = new Uri(Environment.CurrentDirectory + @"\res\template.html");
}
public void Wtest(string str)
{
MessageBox.Show(str);
}
}
[System.Runtime.InteropServices.ComVisible(true)]
public class OprateBasic
{
private WebTest instance;
public OprateBasic(WebTest instance)
{
this.instance = instance;
}
public void HandleTest(string p)
{
instance.Wtest(p);
}
}
js->cs:window.external.HandleTest(「テスト」);
cs->js:this.wbrExam.InvokeScript(「js側名」,new object[{「hello」});