Two open taskpanes side by side

蓝咒 提交于 2021-02-08 09:17:58

问题


I am making an Office add-in which has two ribbon buttons. Each button is linked to a different TaskpaneId, and clicking on each button opens a different taskpane:

<bt:Urls>
    <bt:Url id="Contoso.Taskpane1.Url" DefaultValue="https://localhost:3000/addin/page1" />
    <bt:Url id="Contoso.Taskpane2.Url" DefaultValue="https://localhost:3000/addin/page2" />
</bt:Urls>

It seems that I have seen some Office Add-ins where two task panes can be shown side by side simultaneously (I forgot which exactly the add-ins are). I need this from time to time, does anyone know how to realise this?


回答1:


Script Lab is one such add-in. All you need to do is create two different buttons that have a ShowTaskpane action with different IDs.

Example from Script Lab's prod manifest: https://github.com/OfficeDev/script-lab/blob/master/manifests/script-lab-prod.xml

            <Control xsi:type="Button" id="PG.CodeCommand">
              <Label resid="PG.CodeCommand.Label" />
              <Supertip>
                <Title resid="PG.CodeCommand.TipTitle" />
                <Description resid="PG.CodeSupertip.Desc" />
              </Supertip>
              <Icon>
                <bt:Image size="16" resid="PG.Icon.Code.16" />
                <bt:Image size="32" resid="PG.Icon.Code.32" />
                <bt:Image size="80" resid="PG.Icon.Code.80" />
              </Icon>
              <Action xsi:type="ShowTaskpane">
                <TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId>  
                        <===== A taskpane ID. This one is a "special" one that allows the taskpane
                               to auto-open if a document is marked as belonging to the add-in.

                <SourceLocation resid="PG.Code.Url" />
                <Title resid="PG.CodeCommand.Title" />
              </Action>
            </Control>
            <Control xsi:type="Button" id="PG.RunCommand">
              <Label resid="PG.RunCommand.Label" />
              <Supertip>
                <Title resid="PG.RunCommand.TipTitle" />
                <Description resid="PG.RunSupertip.Desc" />
              </Supertip>
              <Icon>
                <bt:Image size="16" resid="PG.Icon.Run.16" />
                <bt:Image size="32" resid="PG.Icon.Run.32" />
                <bt:Image size="80" resid="PG.Icon.Run.80" />
              </Icon>
              <Action xsi:type="ShowTaskpane">
                        <===== Whereas this one dosn't specify a taskpane ID,
                               and so it is different by default (but probably
                               should be explicit, come to think of it...)

                <SourceLocation resid="PG.Run.Url" /> 
                <Title resid="PG.RunCommand.Title" />
              </Action>
            </Control>

For the auto-open in particular, see https://dev.office.com/docs/add-ins/design/automatically-open-a-task-pane-with-a-document.



来源:https://stackoverflow.com/questions/44896640/two-open-taskpanes-side-by-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!