Question

How do I debug a RoutedUICommand when the associated UIElement is disabled.

For example, consider the ContextMenu. Since it exists in a different VisualTree, a command written with the menu item might not be able to propagate from it to the parent where it has been subscribed. In such scenarios, imagine that the source code is so huge, how do I debug. Are there any tools to assist me in finding these kind of errors/mistakes.

Was it helpful?

Solution

The "Output" window of Visual Studio shows some information about data binding and commands. You can increase the output by setting the appropriate options in "Tools-Options-Debugging-Output Window-WPF Trace Settings".

Regarding the deactivated state: If "CanExecute" is not specified, it will always evaluate to "true". Check the "CanExecute" method or disable it for debugging.

OTHER TIPS

It sounds like your CommandBinding isn't making use of a CanExecute handler. Some example XAML would be helpful here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top