If you want to use Custom Routed commands , you should use a more detailed definition.
Declare the routed command as static in the class, and then use it in XAML using x:Static . You can find the answer here .
For completeness, I post the appropriate code from the answer here:
namespace MyApp.Commands { public class MyApplicationCommands { public static RoutedUICommand ImportExcelCmd = new RoutedUICommand("Import excel command", "ImportExcelCmd", typeof(MyApplicationCommands)); } }
Xaml
<Window x:Class="..." ... xmlns:commands="clr-namespace:MyApp.Commands"> ... <Window.CommandBindings> <CommandBinding Command="{x:Static commands:MyApplicationCommands.ImportExcelCmd}" CanExecute="ImportExcelCmd_CanExecute" Executed="ImportExcelCmd_Executed" /> </Window.CommandBindings>
Rohit vats
source share