ScrollViewer cuts my the image – silverlight 4 – Education Career Blog

I am trying to create a simple image viewer in silverlight.
my code is this:

<ScrollViewer  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Margin="0" Padding="0" Width="300" Height="300">
        <Canvas Width="600" Height="400" Margin="0">
            <Image Source="/MapViewer;component/Images/imageFileName.jpg" Stretch="None" Margin="0,0,90,5"></Image>

(I used the Canvas because in the future I would like to paint more fixed elements on the image, such as lines, polylines, etc)

This code is working ok except the fact that the ScrollViewer cuts the image: say the image is 800×600, than I can view around 700×500. I dont know if that was clear enough, so I will add a picture:
(this is the original image)
alt text

(and this is the picture, as viewed in my application)
alt text

As you can see, I cannot view the bottom right corner of the image… can somebody please tell me how to fix this?


It is not the scroll viewer cropping your image, it is the fixed-size canvas where you placed it. If you want your entire image to be visible you need to set the canvas size to be exactly the same size as your image.

Leave a Comment