Какое использование имеет RoutedCommand' конструктор класса ownertype аргумент?

Цветной XML-файл находится в папке значений, где он должен содержать цветовые значения. С тегом ресурсов.

<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color name="green">#00ff00</color>

9
задан David Schmitt 8 June 2009 в 13:59
поделиться

1 ответ

The source for RoutedCommand shows that the type becomes the OwnerType property. This property is queried ultimately by the following private method when getting InputGestures. So it looks as though this type is being used to lookup a (hard-coded) set of Commands based on the type that created the RoutedCommand.

private InputGestureCollection GetInputGestures()
{
    if (this.OwnerType == typeof(ApplicationCommands))
{
    return ApplicationCommands.LoadDefaultGestureFromResource(this._commandId);
}
if (this.OwnerType == typeof(NavigationCommands))
{
    return NavigationCommands.LoadDefaultGestureFromResource(this._commandId);
}
if (this.OwnerType == typeof(MediaCommands))
{
    return MediaCommands.LoadDefaultGestureFromResource(this._commandId);
}
if (this.OwnerType == typeof(ComponentCommands))
{
    return ComponentCommands.LoadDefaultGestureFromResource(this._commandId);
}
return new InputGestureCollection();
}
6
ответ дан 4 December 2019 в 21:11
поделиться
Другие вопросы по тегам:

Похожие вопросы: