UserControl不在Word中显示添加

时间:2017-08-28 16:46:24

标签: c# wpf

我正在尝试在加载加载时打开用户控件。以下是Add-in Startup事件处理程序中的代码:

    private SidePane sidePane;
    private Microsoft.Office.Tools.CustomTaskPane cTP;

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        sidePane = new SidePane();
        cTP = this.CustomTaskPanes.Add(sidePane, "MyTaskPane");
        cTP.Visible = true;
    }

当在侧窗格中打开任何显示时,可能是什么问题?

1 个答案:

答案 0 :(得分:0)

您需要设置为width属性

    public Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane { get; set; }
    public CustomPaneUserControl cPaneUserControl = new CustomPaneUserControl();


    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(cPaneUserControl, "Verime");
        myCustomTaskPane.Width = 300;
        myCustomTaskPane.Visible = true;
        myCustomTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
    }