This is a mirror of official site: http://jasper-net.blogspot.com/

89. File Drag-And-Drop Support In Silverlight

| Sunday, September 19, 2010
In this entry, I will talk about drop support that came with Silverlight 4. It is actually very simple to use and you can take the advantage of it if you happen to create a simple Silverlight Image Editor. This is a simple introduction to an editor currently I am working to customize images and in future apply adobe effects. However, in this entry, I will talk about only image(s) drag and drop from external place to your Silverlight application.

You can see the live example here [live demo]  

The SOURCE CODE(.zip) is at the end of the page for download.

First I will start coding drag feature. An image at the moment can easily be dragged using the default MouseDragElementBehavior. So just add that to your image and it will become draggable as shown in the code below.

MainPage.xaml

   <Grid x:Name=”LayoutRoot” Background=”Black”>
       <Image x:Name=”DropImage” Width=”400″ Cursor=”Hand”>
           <i:Interaction.Behaviors>
               <ei:MouseDragElementBehavior ConstrainToParentBounds=”True”/>
           </i:Interaction.Behaviors>
       </Image>
   </Grid>

Silverlight is too fun, when coding gets this simple  . So the image can now be dragged around. Now lets add the drop feature.

Read more: Sharker Khaleed Mahmud Silverlight Tips & Tricks

Posted via email from .NET Info

0 comments: