2011-11-07 7 views
2

私はリボンクラスでアクセスできるSetting.settingsファイルにブール値のプロパティSettings.Default.MarkAsReadを持っています。私がしたいのは、このプロパティの値に応じて、バックステージセクションのチェックボックスの値を設定することです。また、ユーザーがそれを変更した場合は、新しい値を保存する必要があります。Officeアドインのバックステージのチェックボックスの値にアクセスするには?

どうにかできますか?

これは私の(簡体字)xmlです:私はRibbon_LoadメソッドからのXML要素にアクセスする方法を見つけることができませんでしたので、私は私のリボンクラスのブールプロパティを作成しました

<?xml version="1.0" encoding="UTF-8"?> 
<customUI onLoad="Ribbon_Load" 
     xmlns="http://schemas.microsoft.com/office/2009/07/customui"> 
    <backstage> 
    <tab id="MyBackstageSection" label="MyBackstageSection" 
       columnWidthPercent="30" insertAfterMso="TabInfo" visible="true" > 
     <firstColumn> 
     <group id="grpOne" label="Configuration"> 
      <bottomItems> 

       <checkBox id="markAsRead" label="Mark as read" 
           getPressed="markAsRead_GetPressed" /> 

       <button id="save" label="Save Preferences" onAction="save_Click"/> 

      </bottomItems>   
     </group> 
     </firstColumn> 
    </tab> 
    </backstage> 
</customUI> 

答えて

2

のxml:

<checkBox id="markAsRead" label="Mark as read" 
      onAction="markAsRead_OnAction" getPressed="markAsRead_GetPressed"/> 

のC#:

OnActionコールバックを使用して更新
private bool MarkAsRead { get; set; } 

    public bool markAsRead_GetPressed(Office.IRibbonControl control) 
    { 
     this.MarkAsRead = Settings.Default.MarkAsRead; 
     return this.MarkAsRead; 
    } 

    public void markAsRead_OnAction(Office.IRibbonControl control, bool isPressed) 
    { 
     this.MarkAsRead = isPressed; 
    } 
関連する問題