Intersoft ClientUI Documentation
DropEvent Field



Identifies the Drop routed event.
Syntax
Public Shared ReadOnly DropEvent As RoutedEvent
Dim value As RoutedEvent
 
value = DragDrop.DropEvent
public static readonly RoutedEvent DropEvent
public:
static readonly RoutedEvent^ DropEvent
Example

The following code shows how create a copy of dragged object and add it to drop target.

All drag-drop events are built on routed event architecture including the DropEvent. To learn more about routed event, see Routed Events overview.
XAML
Copy Code
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
    <i:Interaction.Behaviors>
        <Intersoft:DragDropBehavior IsDragable="False" DragEffect="Copy"/>
    </i:Interaction.Behaviors>
    <Image Source="folder.png" Height="64" Width="64">
        <i:Interaction.Behaviors>
                <Intersoft:DragDropPointBehavior IsDragable="True"/>
        </i:Interaction.Behaviors>
    </Image>
    <TextBlock Text="My Archive" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="100" Width="100" Background="Gray">
    <i:Interaction.Behaviors>
        <Intersoft:DropTargetBehavior TooltipText="Drop here." DropBehavior="Replace"/>
    </i:Interaction.Behaviors>
</Grid>
C#
Copy Code
public MainPage()
{
    // Required to initialize variables
    InitializeComponent();

    ISEventManager.RegisterInstanceHandler(
        this.LayoutRoot, // any element in the routed path which applicable in your scenario
        DragDrop.DropEvent, // the routed event
        new Intersoft.Client.UI.Controls.Interactivity.DragEventHandler(DropTarget_Drop), // the event handler
        true);
}

private void DropTarget_Drop(object sender, Intersoft.Client.UI.Controls.Interactivity.DragEventArgs e)
{
    // get the source object.
    UIElement sourceElement = e.GetSourceElement();
    StackPanel panel = sourceElement as StackPanel;
    Image image = VisualTreeHelper.GetChild(panel, 0) as Image;
    TextBlock text = VisualTreeHelper.GetChild(panel, 1) as TextBlock;

    // create the copy object.
    StackPanel copyPanel = new StackPanel() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
    Image copyImage = new Image() { Source = image.Source, Height = 64, Width = 64 };
    TextBlock copyText = new TextBlock() { Text = text.Text };
    copyPanel.Children.Add(copyImage);
    copyPanel.Children.Add(copyText);
    copyPanel.Opacity = 0; // to make the return animation smooth.

    // register the copy object.
    List<UIElement> elements = new List<UIElement>();
    elements.Add(copyPanel);
    e.SetDropElements(elements); // this method basically set the object that going to be added to the drop target
                                 // since this is copy scenario, we add the copied object, but theoritically you can use any object even multiple objects
}
Remarks

This is a bubbling event raised when an object is droppted into drop target. To learn about the drag drop events sequence see Drag-drop Framework Overview.

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DragDrop Class
DragDrop Members

Concepts

Drag-drop Framework Overview

Send Feedback