views:

21

answers:

1

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>
        </Canvas>
    </ScrollViewer>

(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 800x600, than I can view around 700x500. 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?

+1  A: 

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.

Murven
Indeed you are right, and now it makes perfect sense to me (I am new with the visual tree concept of the WPF \ Silverlight...). Thanks a lot!
ET

related questions