Hello,
I am using MVVM to implement my Drag and Drop in my TreeView. I am using eventtrigger to bind my command when DragEnd event takes place. In Viewmodel, when the command calls my update method to call the appropriate service. But my issue is figuring out the previous and the new parent of the child/node/radtreviewitem that had been dragged and dropped. So that when i call my service I can tell what parent child is being deleted and which parent is getting a new child. I hope i am making sense here and your help ASAP is very much appreciated.
I am attaching sample of my code. Hope this helps. Thank You very much.
Thank You in advance,
I am using MVVM to implement my Drag and Drop in my TreeView. I am using eventtrigger to bind my command when DragEnd event takes place. In Viewmodel, when the command calls my update method to call the appropriate service. But my issue is figuring out the previous and the new parent of the child/node/radtreviewitem that had been dragged and dropped. So that when i call my service I can tell what parent child is being deleted and which parent is getting a new child. I hope i am making sense here and your help ASAP is very much appreciated.
I am attaching sample of my code. Hope this helps. Thank You very much.
<
telerik:RadTreeView
x:Name
=
"tlrkTree"
ItemsSource
=
"{Binding TreeData, Mode=TwoWay}"
BorderBrush
=
"Gray"
BorderThickness
=
"1"
Grid.Row
=
"2"
ItemContainerStyle
=
"{StaticResource RadTreeViewStyle}"
Width
=
"Auto"
Height
=
"400"
Margin
=
"2,2,2,2"
IsDragDropEnabled
=
"True"
IsDragTooltipEnabled
=
"True"
IsDropPreviewLineEnabled
=
"True"
SelectedItem
=
"{Binding SelectedTreeNode, Mode=TwoWay}"
>
<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"DragEnded"
>
<
i:InvokeCommandAction
Command
=
"{Binding DragEndCommand}"
CommandParameter
=
"{Binding}"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
<
telerik:RadTreeView.ItemTemplate
>
<
telerik:HierarchicalDataTemplate
ItemsSource
=
"{Binding Children}"
>
<
StackPanel
>
<
TextBlock
x:Name
=
"textBlock"
>
<
Run
Text
=
"{Binding Name, Mode=TwoWay}"
/>
</
TextBlock
>
</
StackPanel
>
</
telerik:HierarchicalDataTemplate
>
</
telerik:RadTreeView.ItemTemplate
>
</
telerik:RadTreeView
>
private
readonly
ITreeDataService _treeDataService ;
private
TreeNodeItemData _selectedTreeNode;
private
DelegateCommand<
object
> _dragEndCommand;
[ImportingConstructor]
public
TreeDataViewModel( ITreeDataService treeDataService)
{
_treeDataService = treeDataService;
_dragEndCommand =
new
DelegateCommand<
object
>(DragEnded);
}
public
ICommand DragEndCommand
{
get
{
return
_dragEndCommand; }
}
public
TreeNodeItemData SelectedTreeNode
{
get
{
return
_selectedTreeNode;
}
set
{
_selectedTreeNode= value;
}
}
public
void
DragEnded(
object
selectedItems)
{
//Previous Parent and the New Parent Node of the Selected Item - SelectedTreeNode
}
Thank You in advance,