So here I am again, with a probably supidly simple question for you, but it drives me crazy and I can't seem to find a solution to what I'm planning to do.
I'm generating a TreeView through a recursive DataTable
Datatable dtStorage;
ds.Tables.Add(dtStorage);
//add a relationship
ds.Relations.Add("rsParentChild", ds.Tables["Storagedata"].Columns["ID"],
ds.Tables["Storagedata"].Columns["CONTENTOF"]);
_rootNodes = ds.Tables["Storagedata"].DefaultView;
_rootNodes.RowFilter = "CONTENTOF IS NULL";
treeView.ItemsSource = _rootNodes;
Here is the XAML of the TreeView:
<TreeView ContextMenuOpening="TextBlock_ContextMenuOpening" ItemsSource="{Binding RootNodes}" x:Name="treeView" SelectedItemChanged="treeView_SelectedItemChanged" BorderBrush="#FFCACACA" VerticalAlignment="Stretch" FontFamily="Courier New" Margin="0,0,-0.4,-0.2"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling">
<TreeView.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Red" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="Red" />
</TreeView.Resources>
<TreeView.ItemTemplate >
<HierarchicalDataTemplate ItemsSource="{Binding rsParentChild}" >
<StackPanel Tag="{Binding LABEL}" Orientation="Horizontal" ToolTip="{Binding ADDITIONALINFO}" Margin="0,2,0,0" >
<Image x:Name="TheImage" Tag="{Binding TYPE}" Margin="0,0,2,0" Width="20" Height="20">
<!--Loaded="Image_Loaded"-->
<Image.ToolTip>
<TextBlock Text="{Binding ID, StringFormat=ID:{0}}" />
</Image.ToolTip>
</Image>
<TextBlock Text="{Binding LABEL}" ContextMenuOpening="TextBlock_ContextMenuOpening" VerticalAlignment="Center" Padding="2,0,0,0" ToolTip="{Binding ADDITIONALINFO}" >
</TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
So far so good. My Treeview is creates as expected and I get a nice Treeview.
But I'd like to get a Drag & Drop function going.
My Problem is, and that's why almost any Tutorial I searched didn't work for me, I don't have TreeViewItems.
For me there are DataRowViews.
Is it still possible to add a Simple Drag and Drop funcionallity?
I want to move ID-1 to ID-2, where ID-1 is the selected value and ID-2 is the target DataRowView.
Any help would be appretiated. Tipps, hints, solutions or critique.
Thanks in advance