I am trying to understand the constructor parameters of RoutedUICommand
.
ownerType
argument for?null
or typeof(object)
as ownerType
?ownerType
, when calling the empty constructor?My current context is following:
public static class CustomApplicationCommands
{
public static RoutedUICommand SettingsCommand = new RoutedUICommand(
text: "Opens the settings window",
name: nameof(SettingsCommand),
ownerType: typeof(object), // ???
inputGestures: new InputGestureCollection(new InputGesture[] {
new KeyGesture(Key.F10)
})
);
}
Feel free to ask for more information. I will really appreciate your answers. Thank you!
What is the ownerType argument for?
It's used internally to convert commands to and from strings, e.g., when reading or writing Xaml. It's also used in computing the Text
property.
Is it a valid solution to just pass
null
ortypeof(object)
as ownerType?
What is the value ofownerType
, when calling the empty constructor?
Yes, you may pass null
, and that is indeed what happens when calling the default constructor.