Identifies the Drop routed event.
Syntax
Visual Basic (Declaration) | |
---|
Public Shared ReadOnly DropEvent As RoutedEvent |
Delphi | |
---|
public field DropEvent: RoutedEvent; static; readonly |
Managed Extensions for C++ | |
---|
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
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also