开发者

Silverlight DataGridDragDropTarget. How to drag a data grid item into a stack panel / user control?

开发者 https://www.devze.com 2022-12-22 17:09 出处:网络
I have a DataGrid. I have DataGridDragDropTarget from November Toolkit. I now can drag and drop a data grid item to a 开发者_如何学JAVAlistbox or tree view..

I have a DataGrid. I have DataGridDragDropTarget from November Toolkit.

I now can drag and drop a data grid item to a 开发者_如何学JAVAlistbox or tree view..

However I need to drop the item onto my user control (and add it to a plane stack panel).

There is an article from the guy who wrote all these extension: http://themechanicalbride.blogspot.com/2009/10/silverlight-drag-drop-support-part-2.html

But he is incomprehensive. Did anyone try to do the similar I need?

I would like to use a behavior (custom behavior is fine - I did it before) or toolkit DragDropTarget solution.

I just dont know how to attach to an individual data grid item...


What I did:

a. the grid is wrapped in:

            <dtool:DataGridDragDropTarget msw:DragDrop.AllowDrop="False" ItemDragCompleted="ItemDragCompleted_Handler"
                                          HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">

b. The child user control which is supposed to receive the drop has MouseEnter / MouseLeave events hooked up and the IsMouseInside public property exposed.

c. The event handler as follows:

void ItemDragCompleted_Handler(object sender, ItemDragEventArgs e)
{
    if (ChildControl.IsMouseInside)
    {
        SelectionCollection sel = (e.Data as SelectionCollection);
        ChildControl.AddItem(sel[0].Item as MyData);
...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号