How to set the visiblity of a ribbon button for just the current inspector

Add-in Express™ Support Service
That's what is more important than anything else

How to set the visiblity of a ribbon button for just the current inspector
 
Scott English




Posts: 27
Joined: 2010-01-12
I have a ribbon button that should be shown or hidden depending on the state of the item being inspected (in this case, a contact item).

The ADXRibbonButtons are global in nature, i.e. they affect all instances of the button. Here's the problem scenario:

1. User opens a contact. The state of the contact is inspected and the MyRibbonButton.Visible is set to true. The button correctly appears on the inspector's ribbon.
2. User opens a second contact. The state if this contact is inspected and MyRibbonButton.Visible is set to false. In does not appear on this inspector's ribbon.
3. User switches to the first inspector. The ribbon button on the first inspector suddenly disappears.

If I capture the Inspector.Activate event, and set MyRibbonButton.Visible correctly. Then switching between the two inspectors still causes the ribbon to "flicker" since the button first disappears and then reappers when my code set the Visible property to true (or visa versa).

I don't seem to be able to find any per-inspector "instance" of the ribbon button, and the fact that changing the visible property on one affects the other leads me to think there isn't a per-inspector "instance" of the button. Am I missing something? How should I be doing this?
Posted 01 Jul, 2010 19:08:08 Top
Andrei Smolin


Add-in Express team


Posts: 16656
Joined: 2006-05-11
Hi Scott,

you can use the OnPropertyChanging event provided by all Ribbon components. That event occurs when the Ribbon expects that you can supply a new value for a property of the Ribbon control. The event allows you to learn the current context, i.e. the current window showing your Ribbon controls, such as Outlook.Inspector, Word.Document, etc. It also allows you to get the property being changed and its current value. Finally, you can change that value as required.


Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 02 Jul, 2010 04:38:22 Top
Scott English




Posts: 27
Joined: 2010-01-12
Ah! That works much better. Thanks.
Posted 02 Jul, 2010 09:29:48 Top