Ribbon Menu not updating with CanExecute update

Ribbon for WPF Forum

Posted 13 years ago by Tony Pulokas
Version: 11.1.0544
Avatar
I'm experiencing an issue where a ribbon menu (of buttons) remains grayed out, although the CanExecute functions of the bound commands have been executed and returned true. Once in this situation the only way to get the menu to become enabled is by switching to another tab and then back again. After switching back the buttons are enabled/disabled according to the CanExecute result. The buttons placed directly on the ribbon exhibit the same behavior.

The buttons are linked to global Composite Commands (as per the discussion here). An example button:

<ribbon:Button Label="Close This Data" ImageSourceSmall="/Oasis.Presentation;component/Images/Ribbon/CloseThisRow16.png" ImageSourceLarge="/Oasis.Presentation;component/Images/Ribbon/CloseThisRow32.png" Command="{x:Static modules:GlobalCommands.CloseThisItemCommand}" />
The only case where this doesn't seem to apply is a ribbon menu where one of the commands has a CanExecute that always returns true. This menu is always enabled and all of the buttons on it respond immediately to the results of CanExecute functions being called.

I think that the ribbon buttons should be updating automatically, but perhaps there is some event I can publish or something else I can do to manually make the update happen? Do you have any advice on how to troubleshoot this?

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tony,

By "ribbon menu" do you mean that you have a ribbon:PopupButton (or ribbon:SplitButton) that remains disabled even though a ribbon:Menu of ribbon:Button objects on its popup are all enabled?


Actipro Software Support

Posted 13 years ago by Tony Pulokas
Avatar
Yes, that describes it! I've included a trimmed down code sample for clarity.

<ribbon:Tab ... >
    <ribbon:Group Label="Data">
        
        <!-- Even when the two commands' CanExecutes are called and return true,
             the popup button remains disabled until switching out of and then
             back into this ribbon tab. Ribbon buttons placed directly into the
             ribbon group exhibit the same behavior. -->
        
        <ribbon:PopupButton Label="Move Data" >
            <ribbon:Menu>
                <ribbon:Button Label="Up" Command="{x:Static modules:GlobalCommands.MoveItemUpCommand}" />
                <ribbon:Button Label="Down" Command="{x:Static modules:GlobalCommands.MoveItemDownCommand}" />
            </ribbon:Menu>
        </ribbon:PopupButton>
        
        <!-- One of the CanExecute functions for these commands always returns
             true, and the menu is always enabled AND responds immediately to
             the results of CanExecutes being executed. -->
        
        <ribbon:PopupButton Label="Close" >
            <ribbon:Menu>
                <ribbon:Button Command="{x:Static modules:GlobalCommands.CloseThisItemCommand}" />
                <ribbon:Button Command="{x:Static modules:GlobalCommands.CloseAllItemsCommand}" />
            </ribbon:Menu>
        </ribbon:PopupButton>

    </ribbon:Group>
</ribbon:Tab>
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tony,

What you might want to do is set a Command on the PopupButton that is just used to control its enabled state via the command's CanExecute calls. That way you'll have more precise control over it.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.