Hi,
I would like to drag/drop nodes in XamDataTree using drag drop manager, instead of datatree built in support, so that I can apply common drag/cursor templates.
Inside drop method the drop event arg's drag source and drag target gives me the same node/data reference, because of this I cant drag drop successfully.
However this works fine with if i use built in data tree drag drop support, but I cant apply any templates Please help.
Hello,
Thank you for your post. I have been looking into it and I can suggest you use the built-in Drag & Drop functionality, because by handling the XamDataTree’s NodeDraggingStart event you can use the DragDropStartEventArgs object in the handler and set the DragTemplate and CursorTemplate. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.
Thanks for your response Stefan. I tried with NodeDraggingStart event, but it doens't seem to be working as expected as it always displaying DropNotAllowedCursorTemplate and drops successfully. Please help.
e.DragTemplate = Application.Current.FindResource("DragTemplate"); e.DropNotAllowedCursorTemplate = Application.Current.FindResource("NotAllowedTemplate"); e.MoveCursorTemplate = Application.Current.FindResource("CursorTemplate"); e.CopyCursorTemplate = Application.Current.FindResource("CursorTemplate");
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
No Stefan. It deosn't work for me. Here is the code that I'm working with... Please help.
Xaml:
<ig:XamDataTree ItemsSource="{Binding MyProject.Nodes, Mode=TwoWay}" ActiveDataItem="{Binding ActiveNode, Mode=TwoWay}" NodeLineVisibility="Collapsed" MouseRightButtonDown="OnMouseRightButtonDown" SelectedDataItems="{Binding SelectedNodes, Mode=TwoWay}" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext}" IsDraggable="True" IsDropTarget="True" NodeDragDrop="OnNodeDragDrop" NodeDraggingStart="OnNodeDraggingStart" >
<ig:XamDataTree.EditingSettings> <ig:TreeEditingSettings AllowEditing="True" AllowDeletion="True"/> </ig:XamDataTree.EditingSettings>
<ig:XamDataTree.SelectionSettings> <ig:TreeSelectionSettings NodeSelection="Multiple" /> </ig:XamDataTree.SelectionSettings>
<ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="Nodes" TargetTypeName="Node" IsDropTarget="True" IsDraggable="True"> <ig:NodeLayout.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Image Source="{Binding Data, Converter={StaticResource TypeImageConverter}}" /> <TextBlock Text="{Binding Data.Name}" /> </StackPanel> </DataTemplate> </ig:NodeLayout.ItemTemplate> </ig:NodeLayout> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
Xaml.cs
private void OnNodeDraggingStart(object sender, DragDropStartEventArgs e) { e.DragTemplate = Application.Current.FindResource("DragTemplate") as DataTemplate; e.DropNotAllowedCursorTemplate = Application.Current.FindResource("NotAllowedTemplate") as DataTemplate; e.MoveCursorTemplate = Application.Current.FindResource("CursorTemplate") as DataTemplate; e.CopyCursorTemplate = Application.Current.FindResource("CursorTemplate") as DataTemplate; }
Thanks,
Sreeni
Hello Sreeni,
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
HI Stefan,
The sample that you sent is working fine. But if I do the same thing in my application it's not working. Here is the code:
<ig:XamDataTree.EditingSettings><ig:TreeEditingSettings AllowEditing="True" AllowDeletion="True"/></ig:XamDataTree.EditingSettings>
<ig:XamDataTree.SelectionSettings><ig:TreeSelectionSettings NodeSelection="Multiple" /></ig:XamDataTree.SelectionSettings>
<ig:XamDataTree.GlobalNodeLayouts><ig:NodeLayout Key="Nodes" TargetTypeName="Node" IsDropTarget="True" IsDraggable="True"><ig:NodeLayout.ItemTemplate><DataTemplate><StackPanel Orientation="Horizontal"><Image Source="{Binding Data, Converter={StaticResource TypeImageConverter}}" /><TextBlock Text="{Binding Data.Name}" /></StackPanel></DataTemplate></ig:NodeLayout.ItemTemplate></ig:NodeLayout></ig:XamDataTree.GlobalNodeLayouts></ig:XamDataTree>
private void OnNodeDraggingStart(object sender, DragDropStartEventArgs e){e.DragTemplate = Application.Current.FindResource("DragTemplate") as DataTemplate;e.DropNotAllowedCursorTemplate = Application.Current.FindResource("NotAllowedTemplate") as DataTemplate;e.MoveCursorTemplate = Application.Current.FindResource("CursorTemplate") as DataTemplate;e.CopyCursorTemplate = Application.Current.FindResource("CursorTemplate") as DataTemplate;}
Thanks