This is a migrated thread and some comments may be shown as answers.

Can't use DragEnded

1 Answer 80 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
heavywoody
Top achievements
Rank 1
heavywoody asked on 24 Feb 2010, 07:35 PM
The most bizarre situation.  I am trying to do a drag/drop within the treeview.  But for some reason, my DragEnded event will never fire.  I have put it on both the Treeview and it code.  But when I run the code, I just get the error "There is not source code available for the current location".  Other events will work fine like PreviewDragEnded.  I have tried two different datasources.  Both an ObservableCollection and then also a link query cast ToList().  I have also tried to re-create these events and it makes no difference.  By the error, it acts as if I don't have a handler, but I do!  You will notice I have tried the handler in both code and markup.

Version: 2009.3.1314.35

This is based off a sample you put up describing how to change the index of the sort

Here is what I have in XAML and in code:

<

 

<Telerik:RadTreeView x:Name="treeColumns" MinHeight="500" DragEnded="treeColumns_DragEnded"
                        VerticalAlignment="Top" SelectionMode="Multiple" IsEditable="True" IsDragDropEnabled="True"
                        ItemTemplate="{StaticResource ItemTemplate}"
                        ItemsSource="{Binding Converter={StaticResource convWorkflow}}"></Telerik:RadTreeView> 

 

 

 

 

 

 

treeColumns.DragEnded +=

new RadTreeViewDragEndedEventHandler(treeColumns_DragEnded);

 

 

 

 

 

 

private void treeColumns_DragEnded(object sender, RadTreeViewDragEndedEventArgs e)
        {
            int index;
            WorkFlow draggedItem = e.DraggedItems[0] as WorkFlow;
            WorkFlow targetItem=e.TargetDropItem.DataContext as WorkFlow;
            if (draggedItem != targetItem)
            {
                switch (e.DropPosition)
                {
                    case DropPosition.After:
                        index = e.TargetDropItem.Index + 1;
                        break;
                    case DropPosition.Before:
                        index = e.TargetDropItem.Index - 1;
                        break;
                    case DropPosition.Inside:
                        index = e.TargetDropItem.Items.IndexOf(draggedItem);
                        break;
                    default:
                        index = -1;
                        break;
                }
            }
            else
            {
                index = e.TargetDropItem.Index;
            }
            draggedItem.SortOrder = index;
            DataAccess.ctx.SubmitChanges();
        }

1 Answer, 1 is accepted

Sort by
0
heavywoody
Top achievements
Rank 1
answered on 25 Feb 2010, 03:11 AM
User error!!!  I missed that the datasource had to support IList.  So I just did a .ToList() on my LINQ query and the error went away.
Tags
TreeView
Asked by
heavywoody
Top achievements
Rank 1
Answers by
heavywoody
Top achievements
Rank 1
Share this question
or