Working with Slider in Silverlight


xaml
<
Canvas x:Name="LayoutRoot" Width="640" Height="480">
<StackPanel Orientation="Horizontal">
<Image Name="img" Source="thumbnailCAKKSCJQ.jpg" Canvas.Left="40" Canvas.Top="30" Height="40" Width="40">
</Image>
<Slider Name="slider" Background="Transparent" Height="25" Width="150" Maximum="150" Minimum="0" SmallChange="5" ValueChanged="Slider_ValueChanged" ></Slider>
<HyperlinkButton Click="HyperlinkButton_Click" Content="Home" Width="50" Height="25" HorizontalAlignment="Right" VerticalAlignment="Top"></HyperlinkButton>
</StackPanel>

</Canvas>

c#


private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
if (e.NewValue == start)
{
img.Height = height;
img.Width = width;
}

if (e.NewValue > e.OldValue)
{
img.Height = height + e.NewValue;
img.Width = width + e.NewValue;
}
else
{
img.Height = img.Height - (e.OldValue - e.NewValue);
img.Width = img.Width - (e.OldValue - e.NewValue);
}
}