【问题标题】:VSTO Word 2010 getScreentip getSupertip not firedVSTO Word 2010 getScreentip getSupertip 未触发
【发布时间】:2015-03-01 08:05:32
【问题描述】:

我的自定义 XML 功能区有问题, 回调“onAction”、“getImage”和“getEnabled”工作完美,但 getScreentip 和 getSupertip 不起作用。

XML:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <ribbon startFromScratch="true">
    <qat>
      <sharedControls>
        <button id="Flag_fr-FR"
                onAction="OnActionCallback"
                getScreentip="GetScreentip"
                getSupertip="GetSupertip" 
                getImage="GetImage"/>
        <button id="Flag_en-EN"
                onAction="OnActionCallback" 
                getScreentip="GetScreentip" 
                getSupertip="GetSupertip"
                getImage="GetImage"/>
        <separator id="Sep1" insertAfterQ="FlagEn"/>
        <button id="Refresh"
                insertAfterQ="Sep1" 
                getScreentip="GetScreentip"
                getSupertip="GetSupertip"
                onAction="OnActionCallback"
                getImage="GetImage"/>
        <separator id="Sep2" insertAfterQ="Refresh"/>
        <button id="Search"
                insertAfterQ="Sep2"
                getScreentip="GetScreentip"
                getSupertip="GetSupertip"
                onAction="OnActionCallback"
                getImage="GetImage"/>
        <button id="OnScreenKeyboard" insertAfterQ="Search"
                getScreentip="GetScreentip"
                getSupertip="GetSupertip"
                onAction="OnActionCallback"
                getImage="GetImage"/>
        <button id="Logout" insertAfterQ="OSK"
                getScreentip="GetScreentip"
                getSupertip="GetSupertip"
                onAction="OnActionCallback"
                getEnabled="GetEnabled"
                getImage="GetImage"/>
      </sharedControls>
    </qat>
  </ribbon>
</customUI>

代码隐藏:

public String GetScreetip(Office.IRibbonControl control)
 {
     return ("Test...");
 }

 public String GetSupertip(Office.IRibbonControl control)
 {
     return ("Test");
 }

【问题讨论】:

    标签: c# ms-word vsto


    【解决方案1】:

    首先,您输入了错误的处理程序名称,在您编写的 xml 中 getScreentip="GetScreentip" 但在您编写的代码中 GetScreetip 并错过了 n

    其次,由于某种原因Office忽略了字符组合...,所以它只会显示Test

    除此之外,一切似乎都很好。

    例子:

    功能区.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
        <ribbon>
            <tabs>
                <tab idMso="TabAddIns">
                    <group label="MyAddIn">
                        <button id="buttonAbout"
                                onAction="buttonAbout_Click" 
                                label="About" 
                                getScreentip="buttonAbout_Screentip" 
                                getSupertip="buttonAbout_Supertip" />
                    </group>
                </tab>
            </tabs>
        </ribbon>
    </customUI>
    

    Ribbon.cs

    public void buttonAbout_Click(Office.IRibbonControl control)
    {
        if (control.Id != "buttonAbout")
            return;
        // it's not advised to use MessageBox in Office Addins
        // sometimes it gets blocked by Office
        MessageBox.Show("MyAddin v1.0");
    }
    
    public string buttonAbout_Screentip(Office.IRibbonControl control)
    {
        if (control.Id != "buttonAbout")
            return string.Empty;
        return "About Screentip";
    }
    
    public string buttonAbout_Supertip(Office.IRibbonControl control)
    {
        if (control.Id != "buttonAbout")
            return string.Empty;
        return "About Supertip";
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-13
      相关资源
      最近更新 更多