Can KeyBinding be a resource?

I would like to create a StaticResource KeyBinding, but I cannot figure out how I will de-link to it. So, in my Window.Resources, I can add the following:

<Window.Resources>
        <ResourceDictionary>

            <KeyBinding
                x:Key="CtrlRightKeyBinding"
                Modifiers="Control"
                Key="Right"
                Command="{Binding MyCommand}"
                CommandParameter="{Binding DirectionInfoRight}" />

        </ResourceDictionary>
</Window.Resources>

However, I do not know how to remove the link from it when setting up InputBindings:

<Window.InputBindings>
???
</Window.InputBindings>

Any thoughts or suggestions?

+3
source share
1 answer

Try the following:

<Window.InputBindings>
    <StaticResource ResourceKey="CtrlRightKeyBinding" />
</Window.InputBindings>

See Extending StaticResource Extensions .

+1
source

All Articles