How is the RoutedCommand.Name property used?
The RoutedCommand
class has a Name
property that can be set in the contructor. MSDN has this to say about RoutedCommand.Name
:
This property can be used when referencing a RoutedCommand in XAML.
However, I can't seem to find information on how to do this. Currently, my commands are referenced in XAML like this:
Command="{x:Static someNamespace:Commands.SomeCommand}"
This does does not refer to the command by its Name
property, and works whether or not you set Name
.
What is the purpose of RoutedCommand.Name
, and how can it be used?
RoutedCommand.Name
literally serves a name of RoutedCommand
to bind with DependencyPropery
of some UIElement
, usually MenuItem
or Button
.
Please, refer to the XAML code below, where ApplicationCommands
class is included in System.Windows.Input
namespace(PresentationCore.dll).
<Button Command="{x:Static ApplicationCommands.Open}"
Content="{Binding Source={x:Static ApplicationCommands.Open}, Path=Name}"/>
精彩评论