c# - VSTO Word 2010 getScreentip getSupertip 未触发

标签 c# ms-word vsto

我的自定义 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");
 }

最佳答案

首先,您在编写 getScreentip="GetScreentip" 的 xml 中输错了处理程序名称,但在编写 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>

功能区.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";
}

关于c# - VSTO Word 2010 getScreentip getSupertip 未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12070559/

相关文章:

c# - 最简单的并发模式

c# - 线程问题: Double Lists - introducing cross reference

c# - iOS 应用程序 (Xamarin) 与 iOS XAML 应用程序 (Xamarin.Forms) 与跨平台之间有什么区别

c# - 为什么这是错误的代码?

html - 如何在html中获取书签的页码

java - 最后一行未使用 aspose word for java 合并到 ms word 表中

.net - Font.Color 返回令人困惑的值

c# - 使用 openXML 将 docx/doc 第一个页眉和页脚导出为 docx 文件

c# - Outlook VSTO - 如何识别 Outlook 何时完全加载

c# - 为多个 Outlook 版本的插件制作单个安装程序