Can't use DragEnded

2 posts, 0 answers
  1. heavywoody
    heavywoody avatar
    79 posts
    Member since:
    Oct 2009

    Posted 24 Feb 2010 Link to this post

    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();
            }

  2. heavywoody
    heavywoody avatar
    79 posts
    Member since:
    Oct 2009

    Posted 24 Feb 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top