internal void OnCellHolding(DataGridCellInfo cellInfo, HoldingState holdingState) { if (cellInfo.Column.IsCellFlyoutEnabled && holdingState == HoldingState.Started) { this.CommandService.ExecuteCommand(Telerik.UI.Xaml.Controls.Grid.Commands.CommandId.CellFlyoutAction, new CellFlyoutActionContext(cellInfo, true, CellFlyoutGesture.Holding)); } }
internal bool BeginEdit(ItemInfo info, ActionTrigger trigger, object parameter) { var cell = this.model.CellsController.GetCellsForRow(info.Slot).First(); var cellInfo = new DataGridCellInfo(cell); return(this.BeginEdit(cellInfo, trigger, parameter)); }
internal override void TryFocusCell(DataGridCellInfo cellInfo, FocusState state) { base.TryFocusCell(cellInfo, state); if (cellInfo.Cell == null) { return; } var element = cellInfo.Cell.Container as FrameworkElement; if (element != null) { var control = element as Control; if (control != null) { control.Focus(state); } else { var firstControl = ElementTreeHelper.FindVisualDescendant <Control>(element); if (firstControl != null) { firstControl.Focus(state); } } } }
internal bool CommitEdit(DataGridCellInfo cellInfo, ActionTrigger trigger, object parameter) { var context = new EditContext(cellInfo, trigger, parameter); this.CommandService.ExecuteCommand(CommandId.CommitEdit, context); return(context.IsSuccessful); }
internal void SelectCellInfo(DataGridCellInfo cellInfo, bool select, bool uiSelect) { if (!this.CanSelectCellInfo(cellInfo)) { return; } this.SelectCellUnit(cellInfo, select, uiSelect); this.OnSelectionChanged(); }
private void SelectSingleCellUnit(DataGridCellInfo cellInfo, bool select) { this.selectedCellsSet.Clear(); this.SelectSingleItemCore(cellInfo, select); if (select) { this.selectedCellsSet.Add(cellInfo); } }
internal bool BeginEdit(DataGridCellInfo cellInfo, ActionTrigger trigger, object parameter) { if ((this.editService.IsEditing && !this.CommitEdit()) || !this.CurrencyService.ChangeCurrentItem(cellInfo.RowItemInfo.Item, false, true)) { return(false); } var context = new EditContext(cellInfo, trigger, parameter); this.CommandService.ExecuteCommand(CommandId.BeginEdit, context); return(context.IsSuccessful); }
private void SelectMultipleCellUnits(DataGridCellInfo cellInfo, bool select, bool uiSelect) { if (!select || (uiSelect && this.selectedCellsSet.Contains(cellInfo))) { this.selectedCellsSet.Remove(cellInfo); this.selectedItems.Remove(cellInfo); } else if (select) { this.selectedCellsSet.Add(cellInfo); this.selectedItems.Add(cellInfo); } }
internal void OnCellTap(DataGridCellInfo cellInfo) { if (this.editService.IsEditing) { if (this.UserEditMode == DataGridUserEditMode.External) { this.CancelEdit(); } else if (!this.CommitEdit(new DataGridCellInfo(this.CurrentItem, null), ActionTrigger.Tap, null)) { return; } } switch (this.SelectionMode) { case DataGridSelectionMode.Single: case DataGridSelectionMode.Multiple: this.selectionService.Select(cellInfo.Cell); this.itemToSelectFrom = cellInfo; break; case DataGridSelectionMode.Extended: if (KeyboardHelper.IsModifierKeyDown(VirtualKey.Shift)) { var startColumnAndRow = this.GetExtendedSelectionStartRowAndColumn(); this.selectionService.SelectRange(startColumnAndRow.Item1, startColumnAndRow.Item2, cellInfo.Column.ItemInfo.Slot, cellInfo.RowItemInfo.Slot); } else if (KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)) { this.selectionService.Select(cellInfo.Cell); this.itemToSelectFrom = cellInfo; } else { this.selectionService.ClearSelection(); this.selectionService.Select(cellInfo.Cell); this.itemToSelectFrom = cellInfo; } break; } this.CurrencyService.ChangeCurrentItem(cellInfo.RowItemInfo.Item, true, true); if (cellInfo.Column != null) { cellInfo.Column.TryFocusCell(cellInfo, FocusState.Pointer); } }
/// <summary> /// Removes the selection for the grid cell defined by the specified cell info. /// </summary> public void DeselectCell(DataGridCellInfo item) { var dataGridPeer = FrameworkElementAutomationPeer.FromElement(this) as RadDataGridAutomationPeer; if (dataGridPeer != null && dataGridPeer.childrenCache != null && dataGridPeer.childrenCache.Count > 0) { var cellPeer = dataGridPeer.childrenCache.Where(a => a.Row == item.RowItemInfo.Slot && a.Column == item.Column.ItemInfo.Slot).FirstOrDefault() as DataGridCellInfoAutomationPeer; if (cellPeer != null && cellPeer.ChildTextBlockPeer != null) { cellPeer.RaiseValuePropertyChangedEvent(true, false); } } this.selectionService.SelectCellInfo(item, false, false); }
private Style ComposeCellDecorationStyle(GridCellModel cell) { if (this.cellDecorationStyleCache != null) { return(this.cellDecorationStyleCache); } if (this.cellDecorationStyleSelectorCache != null) { var parentRow = cell.parent as GridRowModel; var selectContext = new DataGridCellInfo(parentRow.ItemInfo.Item, cell.Column); return(this.cellDecorationStyleSelectorCache.SelectStyle(selectContext, null)); } return(null); }
internal void Select(GridCellModel gridCellModel) { switch (this.Owner.SelectionUnit) { case DataGridSelectionUnit.Row: this.SelectItem((gridCellModel.Parent as GridRowModel).ItemInfo.Item, true, true); break; case DataGridSelectionUnit.Cell: var cellInfo = new DataGridCellInfo(gridCellModel.ParentRow.ItemInfo, gridCellModel.Column); this.SelectCellInfo(cellInfo, true, true); break; default: throw new ArgumentException("Unknown selection unit type", "this.Owner.SelectionUnit"); } }
private Style ComposeCellContentStyle(FrameworkElement container, object item) { if (this.cellContentStyleCache != null) { return(this.cellContentStyleCache); } if (this.cellContentStyleSelectorCache != null) { var selectContext = new DataGridCellInfo(item, this); var style = this.cellContentStyleSelectorCache.SelectStyle(selectContext, container); if (style != null) { return(style); } } return(this.DefaultCellContentStyle); }
internal async void Select(GridCellModel gridCellModel, bool uiSelect = true) { await this.RaiseAutomationSelection(gridCellModel); switch (this.Owner.SelectionUnit) { case DataGridSelectionUnit.Row: this.SelectItem(((GridRowModel)gridCellModel.Parent).ItemInfo.Item, true, uiSelect); break; case DataGridSelectionUnit.Cell: var cellInfo = new DataGridCellInfo(gridCellModel.ParentRow.ItemInfo, gridCellModel.Column); this.SelectCellInfo(cellInfo, true, uiSelect); break; default: throw new ArgumentException("Unknown selection unit type", "this.Owner.SelectionUnit"); } }
private Style ComposeCellContentStyle(FrameworkElement container, GridCellModel cell) { if (this.cellContentStyleCache != null) { return(this.cellContentStyleCache); } if (this.cellContentStyleSelectorCache != null) { var parentRow = cell.parent as GridRowModel; var selectContext = new DataGridCellInfo(parentRow.ItemInfo.Item, cell.Column); var style = this.cellContentStyleSelectorCache.SelectStyle(selectContext, container); if (style != null) { return(style); } } return(this.DefaultCellContentStyle); }
private void SelectCellUnit(DataGridCellInfo cellInfo, bool select, bool uiSelect) { if (!this.CanSelectCellInfo(cellInfo)) { return; } switch (this.Owner.SelectionMode) { case DataGridSelectionMode.Single: this.SelectSingleCellUnit(cellInfo, select); break; case DataGridSelectionMode.Multiple: this.SelectMultipleCellUnits(cellInfo, select, uiSelect); break; default: break; } }
internal async void Select(GridCellModel gridCellModel) { var dataGridPeer = FrameworkElementAutomationPeer.FromElement(this.Owner) as RadDataGridAutomationPeer; if (dataGridPeer != null && dataGridPeer.childrenCache != null) { if (dataGridPeer.childrenCache.Count == 0) { dataGridPeer.GetChildren(); } var cellPeer = dataGridPeer.childrenCache.Where(a => a.Row == gridCellModel.ParentRow.ItemInfo.Slot && a.Column == gridCellModel.Column.ItemInfo.Slot).FirstOrDefault() as DataGridCellInfoAutomationPeer; if (cellPeer != null && cellPeer.ChildTextBlockPeer != null) { await Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, () => { cellPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); cellPeer.RaiseValuePropertyChangedEvent(false, true); }); } } switch (this.Owner.SelectionUnit) { case DataGridSelectionUnit.Row: this.SelectItem((gridCellModel.Parent as GridRowModel).ItemInfo.Item, true, true); break; case DataGridSelectionUnit.Cell: var cellInfo = new DataGridCellInfo(gridCellModel.ParentRow.ItemInfo, gridCellModel.Column); this.SelectCellInfo(cellInfo, true, true); break; default: throw new ArgumentException("Unknown selection unit type", "this.Owner.SelectionUnit"); } }
internal void OnCellTap(DataGridCellInfo cellInfo) { if (this.editService.IsEditing) { if (this.UserEditMode == DataGridUserEditMode.External) { this.CancelEdit(); } else if (!this.CommitEdit(new DataGridCellInfo(this.CurrentItem, null), ActionTrigger.Tap, null)) { return; } } this.selectionService.Select(cellInfo.Cell); this.CurrencyService.ChangeCurrentItem(cellInfo.RowItemInfo.Item, true, true); if (cellInfo.Column != null) { cellInfo.Column.TryFocusCell(cellInfo, FocusState.Pointer); } }
/// <summary> /// Selects the grid cell as defined by the specified cell info. /// </summary> /// <remarks> /// In order to select a cell, the <see cref="SelectionUnit"/> value should be <c>DataGridSelectionUnit.Cell</c>. /// </remarks> public void SelectCell(DataGridCellInfo item) { this.selectionService.SelectCellInfo(item, true, false); }
internal void OnCellDoubleTap(DataGridCellInfo cell) { this.BeginEdit(cell, ActionTrigger.DoubleTap, null); }
internal virtual void TryFocusCell(DataGridCellInfo cellInfo, FocusState state) { }
private bool CanSelectCellInfo(DataGridCellInfo cell) { return(cell != null && this.Owner.SelectionMode != DataGridSelectionMode.None && this.Owner.SelectionUnit == DataGridSelectionUnit.Cell); }
/// <summary> /// Selects the grid cell as defined by the specified cell info. /// </summary> /// <remarks> /// In order to select a cell, the <see cref="SelectionUnit"/> value should be <c>DataGridSelectionUnit.Cell</c>. /// </remarks> public void SelectCell(DataGridCellInfo item) { this.UpdateItemToSelectFrom(item); this.selectionService.SelectCellInfo(item, true, false); }