首先,它是一个基于文档的 VSTO 项目(所以那些加载项 VSTO 演练并不真正起作用)。
我能够创建一个 ActionPaneControl 并能够使用 ElementHost 在其中添加一个 WPF 用户控件。启动它的代码如下:
ActionsPaneControl1 apc = new ActionsPaneControl1();
Globals.ThisWorkbook.ActionsPane.Controls.Add(apc);
Globals.ThisWorkbook.ActionsPane.Visible = true;
但是,我正在尝试将参数传递到 WPF 用户控件中。然后我意识到在此代码中指示 WPF 用户控件的代码中没有任何位置。我的猜测是它与 ElementHost 有关。
有人可以帮忙吗?
谢谢
编辑:这是 ActionPaneControl1 类
partial class ActionsPaneControl1
{
private System.ComponentModel.IContainer components = null;
.....
private void InitializeComponent()
{
this.elementHost1 = new
System.Windows.Forms.Integration.ElementHost();
this.elementHost2 = new
System.Windows.Forms.Integration.ElementHost();
this.ucWPF1 = new SWAPAEMonthlyReview.ucWPF();
.....
}