Beispiel #1
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            base.OnPreviewKeyDown(e);

            //在编辑控件按 Tab 切换到下一列
            if (e.Key == Key.Tab)
            {
                bool moveNext = !TreeGridHelper.IsShiftPressed();
                this.Column.EditNextColumnOnTabKey(this, moveNext, e, this.Column);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 选择核心逻辑。
        ///
        /// 处理多选及单选状态下的 SelectionModel 中数据状态。
        /// </summary>
        /// <param name="oldItem"></param>
        /// <param name="newItem"></param>
        private void SelectionCore(object oldItem, object newItem)
        {
            var ctrlPressed  = TreeGridHelper.IsCtrlPressed();
            var shiftPressed = TreeGridHelper.IsShiftPressed();

            //当前是否正处于多选模式下。
            var inMultiSelectionMode = this._forceMultiSelect || ctrlPressed || shiftPressed;

            this.ShiftSelectStart(shiftPressed, oldItem, newItem);

            //如果不是多选状态,则先清空选中行状态。
            var sm = this.SelectionModel;

            if (!inMultiSelectionMode)
            {
                sm.ClearSelectedItems();
            }

            if (newItem != null)
            {
                if (ctrlPressed || this._forceMultiSelect)
                {
                    //反选该行
                    var selected = sm.InnerItems.Contains(newItem);
                    sm.MarkItemSelected(newItem, !selected);
                }
                else if (shiftPressed)
                {
                    sm.ClearSelectedItems();

                    if (this._shiftStartItem != null)
                    {
                        this.ShiftSelectEnd(newItem);
                    }
                }
                else
                {
                    sm.MarkItemSelected(newItem, true);
                }
            }
            else
            {
                if (!this._forceMultiSelect)
                {
                    sm.ClearSelectedItems();
                }
            }
        }