【问题标题】:How to move WPF DataGrid Rows using Drag and Drop?如何使用拖放移动 WPF DataGrid 行?
【发布时间】:2014-11-04 16:03:06
【问题描述】:

我遵循了http://www.hardcodet.net/2009/03/moving-data-grid-rows-using-drag-and-drop 中的示例 我很确定我复制了所有代码,但奇怪的是我看不到任何拖放效果?

有人请看一下复制的代码吗? https://www.dropbox.com/sh/e3hgg8kbfjqx21d/AADyTdHQsg1BOcPGePbBnt1ga?dl=0

【问题讨论】:

    标签: wpfdatagrid


    【解决方案1】:

    我分析了您的代码并发现了问题。

    出现此问题是因为您不小心使用了System.Windows.Controls 而不是Microsoft.Windows.Controls 作为以下行中使用的DataGridRow 的引用

    var row = UIHelpers.TryFindFromPoint<DataGridRow>((UIElement)sender, e.GetPosition(shareGrid));
    

    所以修改MainWindow.xaml.cs中的以下引用

    using System.Windows.Controls;
    

    using Microsoft.Windows.Controls;
    

    如果这有帮助,请告诉我

    【讨论】:

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