Last active
August 29, 2015 14:16
-
-
Save refactorsaurusrex/cb18dc3963c35c5b9a75 to your computer and use it in GitHub Desktop.
WPF: Zoom In An Image On Application Load
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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