How to debug commands

How to debug RoutedUICommand when related UIElement is disabled.

For example, consider ContextMenu. Because it exists in another VisualTree, a command written with a menu item may not propagate from it to the parent object that it was subscribed to. In such scenarios, imagine that the source code is as huge as I am debugging. Are there any tools to help me find such errors / errors.

+4
source share
2 answers

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

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

+1
source

It looks like your CommandBinding is not using the CanExecute handler. Here is an example of XAML.

0
source

All Articles