このトリックを行う必要があります。 を処理し、イベントのDataGridをドラッグし、プログラムによってデータグリッドをスクロールします。
// hook up the row events during the loading row event for the datagrid
private void MyDataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.DragOver += new DragEventHandler(MyRow_DragOver);
e.Row.Drop += new DragEventHandler(MyRow_Drop);
}
private void MyRow_DragOver(object sender, DragEventArgs e)
{
DataGridRow r = (DataGridRow)sender;
MyDataGrid.SelectedItem = r.Item;
// Scroll while dragging...
DependencyObject d = MyDataGrid;
while (!(d is ScrollViewer))
{
d = VisualTreeHelper.GetChild(d, 0);
}
ScrollViewer scroll = d as ScrollViewer;
Point position = MyDataGrid.PointToScreen(Mouse.GetPosition(r));
// create this textbox to test in real time the value of gridOrigin
textBox1.Text = position.ToString();
double topMargin = scroll.ActualHeight * .15;
double bottomMargin = scroll.ActualHeight * .80;
if (position.Y * -1 < topMargin)
scroll.LineUp(); // <-- needs a mechanism to control the speed of the scroll.
if (position.Y * -1 > bottomMargin)
scroll.LineDown(); // <-- needs a mechanism to control the speed of the scroll.
}
あなたは 'MyRow_Drop'ですか? –