Visual state of control element doesn't match return value of On...CanExecute

Topics: Issues / bugs
Aug 29, 2012 at 12:38 PM
Edited Aug 29, 2012 at 1:18 PM


I am using a button in my view and created an EventToCommand trigger.


<catel:StackGrid x:Name="LayoutRoot">
        <Button  Content="Test" >
                <i:EventTrigger EventName="Click">
                    <catel:EventToCommand Command="{Binding TestCommand}" DisableAssociatedObjectOnCannotExecute="True" />



In the view model  I have added an associated command "TestCommand".

For testing purposes  OnTestCommandCanExecute returns "false" always.


       /// <summary>
        /// Gets the TestCommand command.
        /// </summary>
        public Command TestCommand { get; private set; }

        /// <summary>
        /// Method to check whether the TestCommand command can be executed.
        /// </summary>
        /// <returns><c>true</c> if the command can be executed; otherwise <c>false</c></returns>
        private bool OnTestCommandCanExecute()
            return false;

        /// <summary>
        /// Method to invoke when the TestCommand command is executed.
        /// </summary>
        private void OnTestCommandExecute()

OnTestCommandCanExecute gets called when the button is clicked but the visual state of the button always looks as if it is enabled.


Catel.Windows.Interactivity.EventToCommand.UpdateElementState gets called but the field "_disableAssociatedObjectOnCannotExecute" is never assigned a value.

Therefore the property "isEnabled" of the button is not updated.

Is there anything that has to done additionally ?


Best regards

Aug 30, 2012 at 6:21 PM

Thanks for the detailed information. It was a wrong default value of the dependency property. I have fixed this, I will release a new build via NuGet tonight.

Aug 31, 2012 at 7:37 AM

Just tested the fix.
The problem is solved.

Thank you very much.