ZoomFit with F key button

Hi!
I would like to assign the zoom fit to “F” key of the keyboard. How can i do that? Thanks in advance

You just need to call Diagram.Panel.ZoomToFit().

As far as having the “F” key invoke that method, it depends on what platform you are using and whether you are using MVVM and commands. But either way it’s quite independent of GoXam, so you can find the appropriate technique thoroughly described in various places on the web. The simplest solution is to implement a KeyDown event handler.

Hi Walter!
I want to use a command to implement the key event so i use the following XAML code:

go:Diagram.InputBindings

</go:Diagram.InputBindings>

The command “ZoomFitWindowCommand” implements the Panel.ZoomToFit()

But the event of pressing the “f” button it’ s not working and i don’t understand why.

I find the problem. I mus assign the KeyBinding to window and not to Diagram:

<Window.InputBindings>
<KeyBinding x:Name=“Key_f” Key=“f” Command="{Binding<span =“apple-tab-span”="" style=“white-space:pre”> <span =“apple-tab-span”="" style=“white-space:pre”> Path=ZoomFitWindowCommand}" />
<KeyBinding x:Name=“Key_F” Key=“F” Command="{Binding<span =“apple-tab-span”="" style=“white-space:pre”> <span =“apple-tab-span”="" style=“white-space:pre”> Path=ZoomFitWindowCommand}" />
</Window.InputBindings>


I had forgotten also to assign the command to KeyBinding in constructor:

Key_f.Command = new ZoomFitWindowCommand(this);
Key_F.Command = new ZoomFitWindowCommand(this);


It’s working right now!