void OnPointerReleased(object sender, PointerRoutedEventArgs e) { if (e.IsTouch()) { // 触摸模式只支持列排序 if (_pointerID == e.Pointer.PointerId) { ReleasePointerCapture(e.Pointer); _pointerID = null; ChangedSortState(); } return; } if (_isDragging) { if (_dragTgtCol != null) { // 拖拽结束 _owner.FinishedDrag(); Cols cols = _owner.Lv.Cols; int index = cols.IndexOf(_dragTgtCol); cols.Remove(Col); cols.Insert(index, Col); cols.Invalidate(); } else { // 列排序 ChangedSortState(); } } ResetMouseState(); }
internal Col GetDragTargetCol(Col p_col, double p_pos) { int index = -1; Col col; Cols cols = Lv.Cols; for (int i = 0; i < cols.Count; i++) { col = cols[i]; if (p_pos >= col.Left && p_pos <= col.Left + col.Width) { index = i; break; } } // 未找到或还在原来列 if (index == -1 || (col = cols[index]) == p_col) { if (_lastDrag > -1) { _lastDrag = -1; Children.Remove(_tbDrag); _tbDrag = null; } return(null); } int toIndex = index > cols.IndexOf(p_col) ? index + 1 : index; if (toIndex != _lastDrag) { _lastDrag = toIndex; if (_tbDrag == null) { _tbDrag = new TextBlock { Text = "\uE018", FontFamily = Res.IconFont, FontSize = 20, Foreground = Res.RedBrush, VerticalAlignment = VerticalAlignment.Center, }; Children.Add(_tbDrag); } else { InvalidateArrange(); } } return(cols[index]); }
public override CellRange GetMergedRange(int row, int col, bool clip) { // save index of ID column to use in merging logic _colIndex = Cols.IndexOf("ID"); // set flag to use custom data when merging _doingMerge = true; // call base class merging logic (will retrieve data using GetData method) CellRange cellRange = base.GetMergedRange(row, col, clip); // reset flag so GetData behaves as usual _doingMerge = false; // return the merged range return(cellRange); }