Ribbon and Prism, Problem with Commands

Ribbon for WPF Forum

Posted 8 years ago by Jürgen Hölker - dSPACE GbmH
Version: 11.1.0542
Avatar
Hi,

i handle a ButtonClick in the Ribbon in my ViewModel via Prism's DelegateCommands:

public ICommand SignalFilterCommand {get;private set;}
...
SignalFilterCommand = new DelegateCommand<ICheckableCommandParameter>(CommandBinding_Executed, 

CommandBinding_CanExecute);
...
...

internal bool CommandBinding_CanExecute(ICheckableCommandParameter parameter)
{
    if (parameter != null)
    {
        parameter.Handled = true;
    }

    return true;
}

internal void CommandBinding_Executed(ICheckableCommandParameter parameter)
{
    if (parameter.Handled)
    {
        parameter.IsChecked = !parameter.IsChecked;
    }
}
So what I'm trying to do is to set the IsChecked-State of the Button after its beeing checked by the user, the state changes, but i get no visual representation of the check(unchecked). If i move the IsChecked-handling to the CanExecute-method, the state also changes, but the visual representation is always checked...

What's wrong here??

Greets,

**Jürgen**

Comments (1)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jürgen,

The parameter.IsChecked should be set in CanExecute, since that is where we check for it. You also need to maintain the checked state in some external variable (e.g. myFlag).

In CanExecute, you'd add the line:
parameter.IsChecked = myFlag;
In Executed, you'd change to the line:
myFlag = !myFlag;


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.