Hi All, im trying to drag and drop files in my treeview but i have no idea why its breaking down if i run it and try dragind a file.
i'm basically a newby in wpf and the code below is as far i can try please somebody help me on this.
private void TreeViewItem_Drop( object sender, DragEventArgs e)
{
TreeViewItem treeViewItem =
e.Source as TreeViewItem;
TreeViewItem obj =
e.Data.GetData(typeof(TreeViewItem)) as TreeViewItem;
if ((obj.Parent as TreeViewItem) != null)
{
(obj.Parent as TreeViewItem).Items.Remove(obj);
}
else
{
treeViewItem.Items.Remove(obj);
treeViewItem.Items.Insert(0, obj);
e.Handled = true;
}
}
private void TreeViewItem_MouseLeftButtonDown( object sender,MouseButtonEventArgs e)
{
DependencyObject dependencyObject =
_treeview.InputHitTest(e.GetPosition(_treeview))
as DependencyObject;
Debug.Write(e.Source.GetType().ToString());
if (dependencyObject is TextBlock)
{
TreeViewItem treeviewItem = e.Source
as TreeViewItem;
DragDrop.DoDragDrop(_treeview, _treeview.SelectedValue,
DragDropEffects.Move);
e.Handled = true;
}
}
Thanx in advance
Austin