RoutedUICommand 的 ownerType 是什么
What is the ownerType of RoutedUICommand
我正在尝试了解 constructor parameters of RoutedUICommand
。
ownerType
参数有什么用?
- 仅将
null
或 typeof(object)
作为 ownerType
传递是有效的解决方案吗?
- 调用空构造函数时
ownerType
的值是多少?
我当前的上下文如下:
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)
})
);
}
欢迎随时询问更多信息。我将非常感谢您的回答。谢谢!
What is the ownerType argument for?
它在内部用于 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
or typeof(object)
as ownerType?
What is the value of ownerType
, when calling the empty constructor?
是的,您可以传递 null
,这确实是调用默认构造函数时发生的情况。
我正在尝试了解 constructor parameters of RoutedUICommand
。
ownerType
参数有什么用?- 仅将
null
或typeof(object)
作为ownerType
传递是有效的解决方案吗? - 调用空构造函数时
ownerType
的值是多少?
我当前的上下文如下:
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)
})
);
}
欢迎随时询问更多信息。我将非常感谢您的回答。谢谢!
What is the ownerType argument for?
它在内部用于 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?
是的,您可以传递 null
,这确实是调用默认构造函数时发生的情况。