3 つの CommandBarButtons を含む Excel のコンテキスト メニューに CommandBarPopup があります。これらのボタンの 1 つは Web ページを開き、他の 2 つはカスタム作業ウィンドウを開きます。
WPF ユーザー コントロールをホストする要素ホストを含むカスタム作業ウィンドウを表示すると、追加した CommandBarButtons のいずれかが機能しなくなります。カスタム作業ウィンドウを閉じても、まだ機能しません。
カスタム作業ウィンドウ コンテナーと Web ブラウザーで同じことを行うと、正常に動作するようです。
これが私たちが使用しているコードです
private void InitializeComponent()
{
this.elementHost1 = new System.Windows.Forms.Integration.ElementHost();
this.myView = new MyView();
this.SuspendLayout();
//
// elementHost1
//
this.elementHost1.Dock = System.Windows.Forms.DockStyle.Fill;
this.elementHost1.Location = new System.Drawing.Point(0, 0);
this.elementHost1.Name = "elementHost1";
this.elementHost1.Size = new System.Drawing.Size(780, 560);
this.elementHost1.TabIndex = 0;
this.elementHost1.Text = "elementHost1";
this.elementHost1.Child = this.myView;
//
// MyTaskPane
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.elementHost1);
this.Name = "MyTaskPane";
this.Size = new System.Drawing.Size(780, 560);
this.ResumeLayout(false);
}