Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I have a big image in the scrollviewer, so now I need to scale an image to see part of that image on the full screen. I need to do that from my code. How to do that?

share|improve this question
    
See the stackoverflow.com/questions/16930074/…. Maybe help. – Anatoliy Nikolaev Jun 30 '13 at 6:10
    
It's either WPF or WinRT-XAML. Can't be both unless you are asking something fundamental to all XAML UI platforms. I'll assume you are asking about winrt-xaml though since it's a common misconception it is some new version of WPF. What is more relevant though is if it is for Windows 8.0 or Windows 8.1, since the answer might be different for these two. – Filip Skakun Jun 30 '13 at 7:58

1 Answer 1

In Windows 8.0 you would set the ZoomFactor property on the ScrollViewer to scale its content.

In Windows 8.1 the ScrollViewer has a ChangeView() method that takes parameters for zoom factor as well as horizontal and vertical offsets and supports view change animations.

To get it to fill your screen you would compare the ActualWidth or ActualHeight properties of your ScrollViewer and its content and set the zoom factor to the result.

share|improve this answer
    
ChangeView is exactly what I need... Is there any solution for Windows 8.0? I understand that it's possible to use HorisontalOffset/VerticalOffset and ZoomFactor, but I can't figure out how... – Spinifex3 Jul 1 '13 at 11:16
    
Exactly what I said - sv.ZoomFactor = Math.Max(sv.ActualWidth / content.ActualWidth, sv.ActualHeight / content.ActualHeight); – Filip Skakun Jul 1 '13 at 15:23
    
Are you sure that in w8 property ScrollViewer.ZoomFactor has a setter? I think we can't set any value - docs Maybe we should use ZoomToFactor? – jimpanzer Dec 10 '13 at 9:42
    
Yes, that's what I meant. – Filip Skakun Dec 10 '13 at 10:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.