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

DropInfo on DataGrid not being called

4 Answers 108 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 17 Apr 2009, 07:04 AM
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




4 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 21 Apr 2009, 07:28 AM
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.
0
Andrew
Top achievements
Rank 1
answered on 24 Apr 2009, 05:23 AM
Thankyou for the response

I am going to implement an alternative solution by using arrows to navigate rows up and down the GridView
0
GEB
Top achievements
Rank 1
answered on 12 Jul 2009, 12:51 AM
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.
0
Miroslav
Telerik team
answered on 14 Jul 2009, 02:32 PM
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.
Tags
DragAndDrop
Asked by
Andrew
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Andrew
Top achievements
Rank 1
GEB
Top achievements
Rank 1
Share this question
or