DropShadows Images
<UserControl x:Class='SilverlightApplication3.MainPage'
xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:d='http://schemas.microsoft.com/expression/blend/2008'
xmlns:mc='http://schemas.openxmlformats.org/markup-compatibility/2006'
mc:Ignorable='d'
d:DesignWidth='640' d:DesignHeight='480'>
<Canvas x:Name="LayoutRoot" Background="White" >
<Image Height="244" x:Name="Shadow1" Width="324" Opacity="0.6" Canvas.Left="53" Canvas.Top="30" Source="c:/image.png"/>
<Image Height="240" x:Name="Flower1" Width="320" Canvas.Left="50" Canvas.Top="27" Source="c:/image.jpg" Stretch="Fill" Cursor="Hand"/>
<Rectangle Stroke="#7F656565" Height="240" Width="320" Canvas.Left="424" Canvas.Top="31" Fill="#FF656565" StrokeThickness="4" x:Name="Shadow2"/>
<Image Height="240" x:Name="Flower2" Width="320" Source="c:/image.jpg" Stretch="Fill" Canvas.Left="420" Canvas.Top="27" Cursor="Hand"/>
<Canvas Height="245" Width="325" Canvas.Left="112" Canvas.Top="293">
<Canvas Height="242" Width="322" Opacity="0.6" Canvas.Left="3" Canvas.Top="3" x:Name="Shadow3">
<Border Height="240" Width="320" BorderThickness="0,0,3,3" BorderBrush="Red" Background="#BF000000"/>
<Border Height="241" Width="321" BorderThickness="0,0,3,3" BorderBrush="#7F000000"/>
<Border Height="242" Width="322" BorderThickness="0,0,3,3" BorderBrush="Yellow"/>
</Canvas>
<Image Height="240" x:Name="Flower3" Width="320" Source="c:/image.jpg" Stretch="Fill" Canvas.Left="-1" Canvas.Top="-1" Cursor="Hand"/>
</Canvas>
</Canvas>
</UserControl>
//File: Page.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SilverlightApplication3
{
public partial class MainPage : UserControl
{
Point Origin1 = new Point();
Point Origin2 = new Point();
Point Origin3 = new Point();
public MainPage()
{
// Required to initialize variables
InitializeComponent();
}
private void Flower1_MouseDown(object sender, MouseButtonEventArgs e)
{
Flower1.CaptureMouse();
Origin1.X = Convert.ToDouble(Flower1.GetValue(Canvas.LeftProperty));
Origin1.Y = Convert.ToDouble(Flower1.GetValue(Canvas.TopProperty));
Flower1.SetValue(Canvas.LeftProperty, Shadow1.GetValue(Canvas.LeftProperty));
Flower1.SetValue(Canvas.TopProperty, Shadow1.GetValue(Canvas.TopProperty));
}
private void Flower1_MouseUp(object sender, MouseButtonEventArgs e)
{
Flower1.ReleaseMouseCapture();
Flower1.SetValue(Canvas.LeftProperty, Origin1.X);
Flower1.SetValue(Canvas.TopProperty, Origin1.Y);
}
private void Flower2_MouseDown(object sender, MouseButtonEventArgs e)
{
Flower2.CaptureMouse();
Origin2.X = Convert.ToDouble(Flower2.GetValue(Canvas.LeftProperty));
Origin2.Y = Convert.ToDouble(Flower2.GetValue(Canvas.TopProperty));
Flower2.SetValue(Canvas.LeftProperty, Shadow2.GetValue(Canvas.LeftProperty));
Flower2.SetValue(Canvas.TopProperty, Shadow2.GetValue(Canvas.TopProperty));
}
private void Flower2_MouseUp(object sender, MouseButtonEventArgs e)
{
Flower2.ReleaseMouseCapture();
Flower2.SetValue(Canvas.LeftProperty, Origin2.X);
Flower2.SetValue(Canvas.TopProperty, Origin2.Y);
}
private void Flower3_MouseDown(object sender, MouseButtonEventArgs e)
{
Flower3.CaptureMouse();
Origin3.X = Convert.ToDouble(Flower3.GetValue(Canvas.LeftProperty));
Origin3.Y = Convert.ToDouble(Flower3.GetValue(Canvas.TopProperty));
Flower3.SetValue(Canvas.LeftProperty, Shadow3.GetValue(Canvas.LeftProperty));
Flower3.SetValue(Canvas.TopProperty, Shadow3.GetValue(Canvas.TopProperty));
}
private void Flower3_MouseUp(object sender, MouseButtonEventArgs e)
{
Flower3.ReleaseMouseCapture();
Flower3.SetValue(Canvas.LeftProperty, Origin3.X);
Flower3.SetValue(Canvas.TopProperty, Origin3.Y);
}
}
}
Related examples in the same category