Skip to content

Instantly share code, notes, and snippets.

@refactorsaurusrex
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save refactorsaurusrex/cb18dc3963c35c5b9a75 to your computer and use it in GitHub Desktop.
Save refactorsaurusrex/cb18dc3963c35c5b9a75 to your computer and use it in GitHub Desktop.
WPF: Zoom In An Image On Application Load
<!-- Assume a data context with all the appropriate bindings -->
<Window
<Window.InputBindings>
<KeyBinding Key="Up" Command="{Binding ZoomIn}" />
<KeyBinding Key="Down" Command="{Binding ZoomOut}" />
</Window.InputBindings>
<Grid>
<Image Source="{Binding MyPath}" HorizontalAlignment="Center"
VerticalAlignment="Center" Width="{Binding DisplayedWidth}" >
<Image.Triggers>
<EventTrigger RoutedEvent="Image.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Width" From="0"
To="{Binding DisplayedWidth}" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
</Grid>
</Window>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Width" From="0" FillBehavior="Stop"
To="{Binding DisplayedWidth}" Duration="0:0:0.5" />
</Storyboard>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment