I'm trying to use WPF commands for a simple user interface. Most of my command bindings are fine, but I can't work out how to use ones in the SystemCommands class. In my XAML I have:
<Window.CommandBindings>
<CommandBinding Command="ApplicationCommands.New" CanExecute="NewCommandCanExecute" Executed="NewCommandExecuted"/>
<CommandBinding Command="ApplicationCommands.Open" CanExecute="OpenCommandCanExecute" Executed="OpenCommandExecuted"/>
<CommandBinding Command="ApplicationCommands.Save" CanExecute="SaveCommandCanExecute" Executed="SaveCommandExecuted"/>
<CommandBinding Command="SystemCommands.CloseWindow" CanExecute="CloseWindowCanExecute" Executed="CloseWindowExecuted"/>
</Window.CommandBindings>
The ones in ApplicationCommands are working exactly as expected, but the SystemCommand.CloseWIndow
gives the error 'The member "CloseWindow" is not recognized or is not accessible.'
What am I missing?
CodePudding user response:
The RoutedCommand
property is called CloseWindowCommand:
<CommandBinding Command="SystemCommands.CloseWindowCommand" .../>