views:

56

answers:

1

Simple question,

SilverLight 3 application (no toolkit). I want to use an image and a slider. The image is displayed fit to screen on load, and then the slider has to zoom-in and out the image when its value changes. I don't want to use anything else, like deepzoom. How can this be done?

Urgent, Thanks in advance,

A: 

The xaml code below :

<ScrollViewer x:Name="scroll"   HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<layout:LayoutTransformer x:Name="layout"  Background="{x:Null}" >
                                <layout:LayoutTransformer.LayoutTransform>
                                    <ScaleTransform x:Name="contentScale" ScaleX="1.0" ScaleY="1.0" />
                                </layout:LayoutTransformer.LayoutTransform>

                                <Image x:Name="img"   Source="../pin.PNG"  >

                                </Image>
                            </layout:LayoutTransformer>
                        </ScrollViewer>

And on the slidervaluechangedevent :

    this.contentScale.ScaleX = this.contentScale.ScaleY = e.NewValue;
    this.layout.ApplyLayoutTransform();

LayoutTransformer is ther in toolkit, add its reference:

System.Windows.Controls.Layout.Toolkit

Without having a toolkit, u can do it but it doesn't work properly(it will never update the scrollviewer)...try it the below one :

<ScrollViewer x:Name="scroll"   HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Themes:ThemeManager.StyleKey="TreeScrollViewer">

                                <Image x:Name="img"   Source="../charge_chargeline.PNG"  >
                                    <Image.RenderTransform>
                                        <ScaleTransform x:Name="contentScale" ScaleX="1.0" ScaleY="1.0" />
                                    </Image.RenderTransform>
                                </Image>

                        </ScrollViewer>

And on the slidervaluechangedevent :

    `this.contentScale.ScaleX = this.contentScale.ScaleY = e.NewValue`;

Hope it helps :)....

Malcolm
Can;t find the LayoutTransformer, do i need to download the SilverLight toolkit?Please elaborate
Zee99
yes............Download and install
Malcolm
Thanks Malcom, Does installing the toolkit on the developer machine require any additional installation or modification on the production machine where the silverlight app will be finally installed?
Zee99
I hope when silverlight app will be installed it will also store the dlls in some lib folder or some other, so put this dll in your globel lib (where u will be putting other dlls required).Because the final point is you must have that dll physically stored in u r app.(Then it doesn't matters whether its on production machine or developers machine or any other machine)
Malcolm