DropInfo on DataGrid not being called

5 posts, 0 answers
  1. Andrew
    Andrew avatar
    26 posts
    Member since:
    Apr 2009

    Posted 17 Apr 2009 Link to this post

    Hi,

    I am implementing Drag and Drop functionality between two RadGridViews

    I have implemented this in a similar format to
    http://www.telerik.com/community/forums/silverlight/drag-and-drop/drop-to-a-datagridrow.aspx#654538

    I am able to drag and drop between the two RadGridViews, however, I would like to be able to drop the information in whatever row it is dragged to

    My aim was to have OnDragInfo event remove the data entry, then OnDropInfo event add it into the appropriate destination row

            private void OnDragInfoDataGrid(object sender, DragDropEventArgs e) 
            { 
                if (e.Options.Status == DragStatus.DragComplete) 
                { 
                    SomeObjectList.Remove(e.Options.Payload as SomeObject);
                } 
            } 

    If I implement my solution using this method, something unusual happens
    If it is dropped onto the DataGrid itself, the "OnDropInfo" event is called
    However, if I dropped it onto a DataGridRow, then "OnDropInfo" event is not called

    If I comment out the line "SomeObjectList.Remove....", then OnDropInfo is called irrelevant of where I drop it on the DataGrid or a Row




  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 21 Apr 2009 Link to this post

    Hi Andrew,

    I created a simple example where the drop targets are GridViewRows and it seems that the OnDropInfo is called as expected, you can have a look at the attached project.

    The reason why you do not see the event in your case might be that this line

    SomeObjectList.Remove(e.Options.Payload as SomeObject);

    removes the visual object on which the routed event (OnDropInfo) will fire. This means that the event will start traveling down the visual tree, starting at the SomeObject (or its container) but will not reach an event handler because the SomeObject has been removed from its parent.

    If you want, you can open a support ticket and send us a sample project where this occurs and we will have a look at it. 

    Hopefully this will work for you,

    Regards,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Andrew
    Andrew avatar
    26 posts
    Member since:
    Apr 2009

    Posted 24 Apr 2009 Link to this post

    Thankyou for the response

    I am going to implement an alternative solution by using arrows to navigate rows up and down the GridView
  5. GEB
    GEB avatar
    228 posts
    Member since:
    Dec 2008

    Posted 11 Jul 2009 Link to this post

    I have the 'drag from DataGrid' working with multiple selections.  However, I would like to use a ContentTemplate in order to show the array of objects with a specific foreground and background.  I have not been able to determine how to do this yet.  Any examples?  For example, I want the background to be white, and the foreground of the list of items to be black/bold.
  6. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 14 Jul 2009 Link to this post

    Hello GEB,

    You can put anything as the DragCue during DragDrop. What you can try is add a ContentControl. Then as Content you assign the collection of items being dragged. Then you give it a ContentTemplate which has an items control with a template for your items. The ItemTemplate of this inner items control can contain borders, TextBlocks, and other visual items which you can modify. If you assign a collection of the dragged items to the content of the DragCue then the inner items control can have its ItemsSource equal to {Binding}, i.e. bound directly to the items.

    If do not like all the binding, you can create an ItemsControl in code and set its items source and item template properties.

    Alternatively you can build the whole visual object in code, starting from a panel and adding TextBlocks (or other visuals) as needed. Then you assign the panel as DragCue.

    In all these cases you can modify the brushes or fonts of the displayed items.

    Hopefully one of these options will work for you,

    Sincerely yours,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner