Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
drag and drop framework
posted

I am trying to create an application where I can drag and drop into either a Data Tree, list view, or stack panel.

I was hopping that when i drag an item into middle of the list of the one of those control. I would be able to reorder the list and add the item between those 2 items.

how can i tell what position the item is dropped into?

I got the drop event to file but i did not see any indication what position is drop too.

Thanks

Alan

 

Here is my code for the xmal

<Window x:Class="WpfTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ig="http://schemas.infragistics.com/xaml"
mc:Ignorable="d">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<WrapPanel Orientation ="Vertical" Grid.Column="0">
<Label Content="This is Action"/>
<TextBlock Text="Test">
<ig:DragDropManager.DragSource>
<ig:DragSource IsDraggable="True" Drop ="DragSource_Drop" DragChannels="OnlyLocation"/>
</ig:DragDropManager.DragSource>
</TextBlock>
<TextBlock Text="Test2">
<ig:DragDropManager.DragSource>
<ig:DragSource IsDraggable="True" Drop ="DragSource_Drop" DragChannels="OnlyLocation" />
</ig:DragDropManager.DragSource>
</TextBlock>
</WrapPanel>
<ig:XamDataTree BorderThickness="1,1,1,1" Grid.Column="1" BorderBrush="Red"
IsDraggable="True"
IsDropTarget="True"
Name="DataTree">
<ig:DragDropManager.DropTarget>
<ig:DropTarget IsDropTarget="True" DropChannels="OnlyLocation" />
</ig:DragDropManager.DropTarget>
</ig:XamDataTree>
</Grid>
</Window>

code-behind

using System;
using System.Collections.Generic;
using System.Windows.Controls;
using Infragistics.DragDrop;


namespace WpfTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
DataTree.ItemsSource = GetData();
}

private System.Collections.IEnumerable GetData()
{
var testing = new List<string>
{
"testing",
"tsting2"
};
return testing;
}

private void DragSource_Drop(object sender, DropEventArgs e)
{
var testing = DragDropManager.GetDragSource(e.DragSource);
}

//private void DragSource_DragStart(object sender, DragDropStartEventArgs e)
//{

// if (e.OriginalDragSource is TextBlock)
// {
// e.DragSnapshotElement = e.OriginalDragSource;
// }
// else
// {
// e.Cancel = true;
// }
//}

//internal static void Testing(object sender, EventArgs e)
//{
// var dragDropStartEventArgs = (DropEventArgs) e;

// var stackPanel = dragDropStartEventArgs.DropTarget as StackPanel;

// var testing = (Label) dragDropStartEventArgs.DragSource;
// var tes = dragDropStartEventArgs.DropTargetElements;


//}

}

}

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello Alan,

     

    Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I copied the default Style of the XamDataTreeNodeControl in order to make it a DropTarget. This way I was able to determine where exactly the text is being dropped, so I could insert it in the correct place in the collection. Please let me know if this helps you or you need further assistance on this matter.

     

    Looking forward for your reply.

    XamDataTreeDD.zip
Children