zoukankan      html  css  js  c++  java
  • WPF和js交互 调用窗体中的方法

    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 + @"
    es	emplate.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" });

  • 相关阅读:
    我们是如何实现DevOps的
    cmp命令
    全排列II
    chown命令
    两个数组的交集II
    MVVM模式的理解
    chmod命令
    路径总和
    cat命令
    跳水板
  • 原文地址:https://www.cnblogs.com/yuejin/p/3945783.html
Copyright © 2011-2022 走看看