开发者

How is the RoutedCommand.Name property used?

开发者 https://www.devze.com 2023-03-20 05:23 出处:网络
The RoutedCommand class has a Name property that can be set in the contructor. MSDN has this to say about RoutedCommand.Name:

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.

开发者_JAVA技巧

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}"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号