【问题标题】:Silverlight DataGridDragDropTarget. How to drag a data grid item into a stack panel / user control?Silverlight DataGridDragDropTarget。如何将数据网格项拖到堆栈面板/用户控件中?
【发布时间】:2011-01-25 20:18:01
【问题描述】:

我有一个DataGrid。我有来自 11 月工具包的 DataGridDragDropTarget

我现在可以将数据网格项拖放到列表框或树视图中。

但是我需要将项目拖放到我的用户控件上(并将其添加到平面堆栈面板)。

写所有这些扩展的人有一篇文章:http://themechanicalbride.blogspot.com/2009/10/silverlight-drag-drop-support-part-2.html

但他不理解。有没有人尝试做我需要的类似事情?

我想使用一种行为(自定义行为很好 - 我以前做过)或工具包 DragDropTarget 解决方案。

我只是不知道如何附加到单个数据网格项...

【问题讨论】:

    标签: silverlight datagrid silverlight-toolkit


    【解决方案1】:

    我做了什么:

    一个。网格被包裹在:

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

    b.应该接收 drop 的子用户控件已连接 MouseEnter / MouseLeave 事件并暴露了 IsMouseInside 公共属性。

    c。事件处理程序如下:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多