Ribbon and CommandBinding CanExecute

Ribbon for WPF Forum

Posted 14 years ago by BODY
Hi All,

We have some problems with a command binding.
We created a Ribbon with few button like that:

 <ribbon:Group Label="Gestion des fichiers" Width="120">
            <ribbon:PopupButton Label="Nouveau" ImageSourceLarge="../../Img/new-file.png" >
                <ribbon:Menu x:Name="NewFileMenu"/>
            <ribbon:PopupButton Label="Ajouter" ImageSourceLarge="../../Img/add-file.png" >
                <ribbon:Menu x:Name="AddFileMenu"/>
When the tab containing these buttons is hidden, the CanExecute is evaluated.
Otherwise, is not. Do you have some ideas about this ??

private void FileAddCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
    e.CanExecute = MainController.Project != null;

<CommandBinding Command="{x:Static Local:CustomCommands.FileAdd}"

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA

Since Ribbon's often contain hundreds of commands we added a feature to lessen the impact of can-executes continuously firing (which could slow down an app's typing, etc.) by adding a property to button controls called CanUpdateCanExecuteWhenHidden. It returns false by default. You could override any button class and change it to true if you want to have your CanExecute handlers called even when it is hidden.

Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.