Tuesday, 17 May 2016

Altering the Keyboard functionality WPF


    <Window.Resources>
         <!--UI commands.-->
        <RoutedUICommand x:Key="Commands.ZoomOut" />
        <RoutedUICommand x:Key="Commands.ZoomIn" />
    </Window.Resources>

    <Window.InputBindings>       
        <!--Bind keys to commands.-->       
        <KeyBinding
                                                Key="Minus"
                                                Command="{StaticResource Commands.ZoomOut}"
                                                />
        <KeyBinding
                                                Key="Plus"
                                                Command="{StaticResource Commands.ZoomIn}"
                                                />
        <KeyBinding
                                                Key="Space"
                                                Command="{StaticResource Commands.ZoomIn}"
                                                />
     
    </Window.InputBindings>

    <Window.CommandBindings>
       
        <!--Bind commands to event handlers.-->
       
        <CommandBinding
            Command="{StaticResource Commands.ZoomOut}"
            Executed="ZoomOut_Executed"
            />
        <CommandBinding
            Command="{StaticResource Commands.ZoomIn}"
            Executed="ZoomIn_Executed"
            />

    </Window.CommandBindings>

No comments:

Post a Comment