Live Chat Icon For mobile
Live Chat Icon

How can I add a CommandBinding to a window using markup?

Platform: WPF| Category: Input and Commands.

CommandBinding can be added to a window using markup. Note that in XAML, the CommandBindingCollection is not declared in the markup as an element and the collection object is inferred by the type that the property takes and you populate the property element with one or more CommandBinding elements.

[XAML]

<Window.CommandBindings>
  <CommandBinding Command='ApplicationCommands.Open'
                  Executed='OpenCmdExecuted'
                  CanExecute='OpenCmdCanExecute'/>
</Window.CommandBindings>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.