拖拽标记
当在另一条记录上拖动记录时,GridControl会显示一个投递标记。下拉标记是一个可视化的元素,用于指示下拉目标元素。
下图左方为拖拽位置标记,有方为拖拽到子项目中的展示。
简单的位置标记设置办法,更详细内容参见 https://docs.devexpress.com/WPF/119483/controls-and-libraries/data-grid/drag-and-drop/drop-marker:
<dxg:TreeListView AllowDragDrop="True" DragRecordOver="OnDragRecordOver" />
void OnDragRecordOver(object sender, DragRecordOverEventArgs e) { if(e.DropPosition == DropPosition.Inside) { e.DropPosition = e.DropPositionRelativeCoefficient > 0.5 ? DropPosition.After : DropPosition.Before; e.Handled = true; } }
自定义标记样式
<dxg:TableView AllowDragDrop="True"> <dxg:TableView.DropMarkerTemplate> <DataTemplate> <Grid Margin="0,-3,0,-3" IsHitTestVisible="False"> <Border Height="6" Background="Orange" BorderBrush="Gray" BorderThickness="1" VerticalAlignment="{Binding Position, Converter={StaticResource dropPositionConverter}}" /> </Grid> </DataTemplate> </dxg:TableView.DropMarkerTemplate> </dxg:TableView>
public class DropPositionConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return (DropPosition)value == DropPosition.Before ? VerticalAlignment.Top : VerticalAlignment.Bottom; } // ... }