Biggo

I have created a UserControl. The UserControl implements a button. When I press the button I execute an ActivatedCommand in the click eventhandler like so: "UserControlCommands.ActivatedCommand.Execute(xxx,xxx)".

This works well. However - It's important that the whole UserControl is made inactive when CanExecute is set to false in a CommandBinding on the ActivatedCommand.

In other words, that the UserControl has the same behaviour as any other control with a Command property (Button, MenuItem and so on).

How can I do that



Re: Windows Presentation Foundation (WPF) UserControl and command behavior

WPCoder

There's an event available, CanExecuteChanged that fires when the status of CanExecute changes for the RoutedCommand.





Re: Windows Presentation Foundation (WPF) UserControl and command behavior

Biggo

The event doesn't get fired. Can you give me an example of how to implement it



Re: Windows Presentation Foundation (WPF) UserControl and command behavior

WPCoder

CanExecutedChanged

Is that enough to help or are you still not having luck






Re: Windows Presentation Foundation (WPF) UserControl and command behavior

Biggo

Solved it. I seems that the ICommandSource Interface has to be implemented on the UserControl as well.

I followed the example from this article:

http://msdn2.microsoft.com/en-us/library/system.windows.input.icommandsource.aspx

Thanks.

Biggo