Reputation: 5407
I have a ScrollViewer with an Image inside. Everytime i zoom the Image to be greater than my screen, it will bounce back to the left border. Strangely only left, not top, even if the image is larger than my screen, both width and height. BringIntoViewOnFocusChange
does not seem to help.
<UserControl>
<Grid>
<ScrollViewer ZoomMode="Enabled"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BringIntoViewOnFocusChange="False" >
<Image ScrollViewer.BringIntoViewOnFocusChange="False" HorizontalAlignment="Center" VerticalAlignment="Center" />
</ScrollViewer>
</Grid>
</UserControl>
Upvotes: 0
Views: 255
Reputation: 1057
This answer solves the problem. If you don't want to disturb image size, you can use ViewportHeight
and ViewportWidth
properties of ScrollViewer
<Image Width="{Binding ElementName=scrollViewer, Path=ViewportWidth}"
Height="{Binding ElementName=scrollViewer, Path=ViewportHeight}"
ScrollViewer.BringIntoViewOnFocusChange="False"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Source="Assets/image.jpg" />
Upvotes: 1