【发布时间】:2018-01-30 13:08:28
【问题描述】:
我正在尝试了解RoutedUICommand 的constructor 参数。
-
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)
})
);
}
请随时询问更多信息。我将非常感谢您的回答。谢谢!
【问题讨论】:
-
注册命令的类型(在线文档中提到)是指声明你的SettingsCommand的类,即CustomApplicationCommands。
-
如果您调用空构造函数,
ownerType将是null。您可以在referencesource 找到源代码
标签: c# wpf routed-commands