Hi all,
I try to "disable" some ribbon tabs under certain conditions, e.g. the user is in a special mode, then he can no longer use Ribbon Tab-3 and Ribbon Tab-5. However these tabs should remain visible. I managed this by placing a boolean value (enabled = true/false) in the tabs Tag property and handling the event BeforeRibbonTabSelected.So the user can no longer select those tabs.
So far so good! Now I want to disable also the hot tracking for those "disabled" tabs and change the caption text of those tabs to a somehow disabled appearance.
How can can I do this ? Any ideas? DrawFilter?
Thanks! Regards
Michael
In the meantime I guess I may have found somekind of a solution for it via a DrawFilter.
if(drawPhase == DrawPhase.BeforeDrawBackColor){ if(drawParams.Element is RibbonTabItemUIElement) { // Get the underlying ribbon tab control RibbonTab tab = drawParams.Element.GetContext(typeof(RibbonTab)) as RibbonTab; if(tab != null) { // Extract ribbon info object from Tag property if(tab.Tag != null && tab.Tag is RibbonTabInfo) { RibbonTabInfo tabInfo = (RibbonTabInfo) tab.Tag; // Get caption text UI element ImageAndTextDependentTextUIElement captionUIElem = drawParams.Element.GetDescendant(typeof(ImageAndTextDependentTextUIElement)) as ImageAndTextDependentTextUIElement; if(captionUIElem != null) { // Update the enabled field of the UI Element, either disable or re-enable it captionUIElem.Enabled = tabInfo.Enabled; } if(!tabInfo.Enabled) { // Prevent drawing of the background at all return true; } } } }}
Regards
Hi Michael,
This is definitely the right way to go as I was about to send you sample with draw filter as well. However, yours even look better with how the hot track background appearance renders within your implementation. Let me know if you have additional questions or need further assistance regarding this matter.