I am implementing some RoutedUICommand
and could not figure out the purpose of the text
argument. The reason for my question is: I am wondering if it is necessary to translate this text or not. Is it just a descriptive text for the developers?
public static class ProjectCommands
{
public static RoutedUICommand RemoveFoo = new RoutedUICommand(
text: "remove current foo",
name: nameof(RemoveFoo),
ownerType: typeof(ProjectCommands),
inputGestures: new InputGestureCollection(new InputGesture[]{
new KeyGesture(Key.Delete)
})
);
}
The official MSDN documentation does not provide any useful information, regarding this property and I could not see any effect on the UI. The constructor documentation just states: "Descriptive text for the command."
Can someone please can explain the purpose of this property / constrcutor argument? Thank you very much in advance!
This text might be (and actually is) used by controls to provide description of action performed by command in UI, in case such description has not been provided explicitly. One example is MenuItem
:
<Menu>
<MenuItem Command="{x:Static my:ProjectCommands.RemoveFoo}" />
</Menu>
In the above xaml we didn't provide a Header
for menu item, but set a command for it. In such case (if that command is RoutedUICommand
) - RoutedUICommand.Text
will be used as a header. So example above will create menu item with header "remove current foo".
I suppose you can decide yourself if you need to translate it or not given this information.