/// <summary>Gets a <see cref="T:System.Windows.Controls.TextBox" /> control that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding" /> property value.</summary> /// <param name="cell">The cell that will contain the generated element.</param> /// <param name="dataItem">The data item represented by the row that contains the intended cell.</param> /// <returns>A new text box control that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding" /> property value.</returns> // Token: 0x060049B4 RID: 18868 RVA: 0x0014D628 File Offset: 0x0014B828 protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { TextBox textBox = new TextBox(); this.SyncProperties(textBox); base.ApplyStyle(true, false, textBox); base.ApplyBinding(textBox, TextBox.TextProperty); DataGridHelper.RestoreFlowDirection(textBox, cell); return(textBox); }
/// <summary>Gets a read-only <see cref="T:System.Windows.Controls.TextBlock" /> control that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding" /> property value.</summary> /// <param name="cell">The cell that will contain the generated element.</param> /// <param name="dataItem">The data item represented by the row that contains the intended cell.</param> /// <returns>A new, read-only text block control that is bound to the column's <see cref="P:System.Windows.Controls.DataGridBoundColumn.Binding" /> property value.</returns> // Token: 0x060049B3 RID: 18867 RVA: 0x0014D5F0 File Offset: 0x0014B7F0 protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem) { TextBlock textBlock = new TextBlock(); this.SyncProperties(textBlock); base.ApplyStyle(false, false, textBlock); base.ApplyBinding(textBlock, TextBlock.TextProperty); DataGridHelper.RestoreFlowDirection(textBlock, cell); return(textBlock); }
protected override bool OnCoerceIsReadOnly(bool baseValue) { if (DataGridHelper.IsOneWay(_binding)) { return(true); } // only call the base if we dont want to force IsReadOnly true return(base.OnCoerceIsReadOnly(baseValue)); }
/// <summary>Causes the column cell being edited to revert to the specified value.</summary> /// <param name="editingElement">The element that the column displays for a cell in editing mode.</param> /// <param name="uneditedValue">The previous, unedited value in the cell being edited.</param> // Token: 0x060048B9 RID: 18617 RVA: 0x0014A490 File Offset: 0x00148690 protected override void CancelCellEdit(FrameworkElement editingElement, object uneditedValue) { ComboBox comboBox = editingElement as ComboBox; if (comboBox != null && comboBox.EditableTextBoxSite != null) { DataGridHelper.CacheFlowDirection(comboBox.EditableTextBoxSite, comboBox.Parent as DataGridCell); DataGridHelper.CacheFlowDirection(comboBox, comboBox.Parent as DataGridCell); } base.CancelCellEdit(editingElement, uneditedValue); }
/// <summary> /// Creates the visual tree for text based cells. /// </summary> protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { ComboBox comboBox = new ComboBox(); ApplyStyle(/* isEditing = */ true, /* defaultToElementStyle = */ false, comboBox); ApplyColumnProperties(comboBox); DataGridHelper.RestoreFlowDirection(comboBox, cell); return(comboBox); }
/// <summary>Performs any required validation before exiting the editing mode.</summary> /// <param name="editingElement">The element that the column displays for a cell in editing mode.</param> /// <returns> /// <see langword="false" /> if validation fails; otherwise, <see langword="true" />.</returns> // Token: 0x060048BA RID: 18618 RVA: 0x0014A4E0 File Offset: 0x001486E0 protected override bool CommitCellEdit(FrameworkElement editingElement) { ComboBox comboBox = editingElement as ComboBox; if (comboBox != null && comboBox.EditableTextBoxSite != null) { DataGridHelper.CacheFlowDirection(comboBox.EditableTextBoxSite, comboBox.Parent as DataGridCell); DataGridHelper.CacheFlowDirection(comboBox, comboBox.Parent as DataGridCell); } return(base.CommitCellEdit(editingElement)); }
/// <summary> /// Creates the visual tree for cells. /// </summary> protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { TextBox textBox = new TextBox(); ApplyStyle(/* isEditing = */ true, /* defaultToElementStyle = */ false, textBox); ApplyBinding(textBox, TextBox.TextProperty); DataGridHelper.RestoreFlowDirection(textBox, cell); return(textBox); }
protected internal override void RefreshCellContent(FrameworkElement element, string propertyName) { DataGridCell cell = element as DataGridCell; if (cell != null) { bool isCellEditing = cell.IsEditing; if ((string.Compare(propertyName, "ElementStyle", StringComparison.Ordinal) == 0 && !isCellEditing) || (string.Compare(propertyName, "EditingElementStyle", StringComparison.Ordinal) == 0 && isCellEditing)) { cell.BuildVisualTree(); } else { ComboBox comboBox = cell.Content as ComboBox; switch (propertyName) { case "SelectedItemBinding": ApplyBinding(SelectedItemBinding, comboBox, ComboBox.SelectedItemProperty); break; case "SelectedValueBinding": ApplyBinding(SelectedValueBinding, comboBox, ComboBox.SelectedValueProperty); break; case "TextBinding": ApplyBinding(TextBinding, comboBox, ComboBox.TextProperty); break; case "SelectedValuePath": DataGridHelper.SyncColumnProperty(this, comboBox, ComboBox.SelectedValuePathProperty, SelectedValuePathProperty); break; case "DisplayMemberPath": DataGridHelper.SyncColumnProperty(this, comboBox, ComboBox.DisplayMemberPathProperty, DisplayMemberPathProperty); break; case "ItemsSource": DataGridHelper.SyncColumnProperty(this, comboBox, ComboBox.ItemsSourceProperty, ItemsSourceProperty); break; default: base.RefreshCellContent(element, propertyName); break; } } } else { base.RefreshCellContent(element, propertyName); } }
/// <summary> /// Creates the visual tree for text based cells. /// </summary> protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem) { TextBlock textBlock = new TextBlock(); SyncProperties(textBlock); ApplyStyle(/* isEditing = */ false, /* defaultToElementStyle = */ false, textBlock); ApplyBinding(textBlock, TextBlock.TextProperty); DataGridHelper.RestoreFlowDirection(textBlock, cell); return(textBlock); }
private static object OnCoerceStyle(DependencyObject d, object baseValue) { var cell = d as DataGridCell; return(DataGridHelper.GetCoercedTransferPropertyValue( cell, baseValue, StyleProperty, cell.Column, DataGridColumn.CellStyleProperty, cell.DataGridOwner, DataGrid.CellStyleProperty)); }
// Token: 0x060046F8 RID: 18168 RVA: 0x00141F1C File Offset: 0x0014011C private static void OnAnyGotFocus(object sender, RoutedEventArgs e) { DataGridCell dataGridCell = DataGridHelper.FindVisualParent <DataGridCell>(e.OriginalSource as UIElement); if (dataGridCell != null && dataGridCell == sender) { DataGrid dataGridOwner = dataGridCell.DataGridOwner; if (dataGridOwner != null) { dataGridOwner.FocusedCell = dataGridCell; } } }
/// <summary> /// General notification for DependencyProperty changes from the grid or from columns. /// </summary> internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, DataGridNotificationTarget target) { DataGridColumn column = d as DataGridColumn; if ((column != null) && (column != Column)) { // This notification does not apply to this cell return; } // All the notifications which are to be handled by the cell if (DataGridHelper.ShouldNotifyCells(target)) { if (e.Property == DataGridColumn.WidthProperty) { DataGridHelper.OnColumnWidthChanged(this, e); } else if (e.Property == DataGrid.CellStyleProperty || e.Property == DataGridColumn.CellStyleProperty || e.Property == StyleProperty) { DataGridHelper.TransferProperty(this, StyleProperty); } else if (e.Property == DataGrid.IsReadOnlyProperty || e.Property == DataGridColumn.IsReadOnlyProperty || e.Property == IsReadOnlyProperty) { DataGridHelper.TransferProperty(this, IsReadOnlyProperty); } else if (e.Property == DataGridColumn.DisplayIndexProperty) { TabIndex = column.DisplayIndex; } else if (e.Property == DataGrid.IsKeyboardFocusWithinProperty) { UpdateVisualState(); } } // All the notifications which needs forward to columns if (DataGridHelper.ShouldRefreshCellContent(target)) { if (column != null && NeedsVisualTree) { if (!string.IsNullOrEmpty(propertyName)) { column.RefreshCellContent(this, propertyName); } else if (e != null && e.Property != null) { column.RefreshCellContent(this, e.Property.Name); } } } }
/// <summary>Refreshes the contents of a cell in the column in response to a binding change.</summary> /// <param name="element">The cell to update.</param> /// <param name="propertyName">The name of the column property that has changed.</param> // Token: 0x060048B3 RID: 18611 RVA: 0x0014A240 File Offset: 0x00148440 protected internal override void RefreshCellContent(FrameworkElement element, string propertyName) { DataGridCell dataGridCell = element as DataGridCell; if (dataGridCell == null) { base.RefreshCellContent(element, propertyName); return; } bool isEditing = dataGridCell.IsEditing; if ((string.Compare(propertyName, "ElementStyle", StringComparison.Ordinal) == 0 && !isEditing) || (string.Compare(propertyName, "EditingElementStyle", StringComparison.Ordinal) == 0 && isEditing)) { dataGridCell.BuildVisualTree(); return; } ComboBox comboBox = dataGridCell.Content as ComboBox; if (propertyName == "SelectedItemBinding") { DataGridComboBoxColumn.ApplyBinding(this.SelectedItemBinding, comboBox, Selector.SelectedItemProperty); return; } if (propertyName == "SelectedValueBinding") { DataGridComboBoxColumn.ApplyBinding(this.SelectedValueBinding, comboBox, Selector.SelectedValueProperty); return; } if (propertyName == "TextBinding") { DataGridComboBoxColumn.ApplyBinding(this.TextBinding, comboBox, ComboBox.TextProperty); return; } if (propertyName == "SelectedValuePath") { DataGridHelper.SyncColumnProperty(this, comboBox, Selector.SelectedValuePathProperty, DataGridComboBoxColumn.SelectedValuePathProperty); return; } if (propertyName == "DisplayMemberPath") { DataGridHelper.SyncColumnProperty(this, comboBox, ItemsControl.DisplayMemberPathProperty, DataGridComboBoxColumn.DisplayMemberPathProperty); return; } if (!(propertyName == "ItemsSource")) { base.RefreshCellContent(element, propertyName); return; } DataGridHelper.SyncColumnProperty(this, comboBox, ItemsControl.ItemsSourceProperty, DataGridComboBoxColumn.ItemsSourceProperty); }
// Token: 0x06004895 RID: 18581 RVA: 0x00149F18 File Offset: 0x00148118 private static object OnCoerceSortMemberPath(DependencyObject d, object baseValue) { DataGridComboBoxColumn dataGridComboBoxColumn = (DataGridComboBoxColumn)d; string text = (string)baseValue; if (string.IsNullOrEmpty(text)) { string pathFromBinding = DataGridHelper.GetPathFromBinding(dataGridComboBoxColumn.EffectiveBinding as Binding); if (!string.IsNullOrEmpty(pathFromBinding)) { text = pathFromBinding; } } return(text); }
// Token: 0x06004712 RID: 18194 RVA: 0x00142414 File Offset: 0x00140614 private static object OnCoerceClip(DependencyObject d, object baseValue) { DataGridCell cell = (DataGridCell)d; Geometry geometry = baseValue as Geometry; Geometry frozenClipForCell = DataGridHelper.GetFrozenClipForCell(cell); if (frozenClipForCell != null) { if (geometry == null) { return(frozenClipForCell); } geometry = new CombinedGeometry(GeometryCombineMode.Intersect, geometry, frozenClipForCell); } return(geometry); }
private static object OnCoerceIsReadOnly(DependencyObject d, object baseValue) { var cell = d as DataGridCell; var column = cell.Column; var dataGrid = cell.DataGridOwner; // We dont use the cell & 'baseValue' here because this property is read only on cell. // the column may coerce a default value to 'true', so we'll use it's effective value for IsReadOnly // as the baseValue. return(DataGridHelper.GetCoercedTransferPropertyValue( column, column.IsReadOnly, DataGridColumn.IsReadOnlyProperty, dataGrid, DataGrid.IsReadOnlyProperty)); }
private static void OnAnyLostFocus(object sender, RoutedEventArgs e) { // Get the ancestor cell of old focused element. // Set DataGrid.FocusedCell to null, if the cell doesn't // have keyboard focus. DataGridCell cell = DataGridHelper.FindVisualParent <DataGridCell>(e.OriginalSource as UIElement); if (cell != null && cell == sender) { DataGrid owner = cell.DataGridOwner; if (owner != null && !cell.IsKeyboardFocusWithin && owner.FocusedCell == cell) { owner.FocusedCell = null; } } }
private static object OnCoerceSortMemberPath(DependencyObject d, object baseValue) { var column = (DataGridComboBoxColumn)d; var sortMemberPath = (string)baseValue; if (string.IsNullOrEmpty(sortMemberPath)) { var bindingSortMemberPath = DataGridHelper.GetPathFromBinding(column.EffectiveBinding as Binding); if (!string.IsNullOrEmpty(bindingSortMemberPath)) { sortMemberPath = bindingSortMemberPath; } } return(sortMemberPath); }
/// <summary>Gets a read-only <see cref="T:System.Windows.Documents.Hyperlink" /> element that is bound to the column's <see cref="P:System.Windows.Controls.DataGridHyperlinkColumn.ContentBinding" /> property value.</summary> /// <param name="cell">The cell that will contain the generated element.</param> /// <param name="dataItem">The data item represented by the row that contains the intended cell.</param> /// <returns>A new, read-only hyperlink element that is bound to the column's <see cref="P:System.Windows.Controls.DataGridHyperlinkColumn.ContentBinding" /> property value.</returns> // Token: 0x060048F6 RID: 18678 RVA: 0x0014B07C File Offset: 0x0014927C protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem) { TextBlock textBlock = new TextBlock(); Hyperlink hyperlink = new Hyperlink(); InlineUIContainer inlineUIContainer = new InlineUIContainer(); ContentPresenter contentPresenter = new ContentPresenter(); textBlock.Inlines.Add(hyperlink); hyperlink.Inlines.Add(inlineUIContainer); inlineUIContainer.Child = contentPresenter; hyperlink.TargetName = this.TargetName; base.ApplyStyle(false, false, textBlock); base.ApplyBinding(hyperlink, Hyperlink.NavigateUriProperty); this.ApplyContentBinding(contentPresenter, ContentPresenter.ContentProperty); DataGridHelper.RestoreFlowDirection(textBlock, cell); return(textBlock); }
/// <summary> /// Prepares a cell for use. /// </summary> /// <remarks> /// Updates the column reference. /// </remarks> internal void PrepareCell(object item, DataGridRow ownerRow, int index) { Debug.Assert(_owner == null || _owner == ownerRow, "_owner should be null before PrepareCell is called or the same value as the ownerRow."); _owner = ownerRow; DataGrid dataGrid = _owner.DataGridOwner; if (dataGrid != null) { // The index of the container should correspond to the index of the column if ((index >= 0) && (index < dataGrid.Columns.Count)) { // Retrieve the column definition and pass it to the cell container DataGridColumn column = dataGrid.Columns[index]; Column = column; TabIndex = column.DisplayIndex; } if (IsEditing) { // If IsEditing was left on and this container was recycled, reset it here. // Setting this property will result in BuildVisualTree being called. IsEditing = false; } else if ((Content as FrameworkElement) == null) { // If there isn't already a visual tree, then create one. BuildVisualTree(); if (!NeedsVisualTree) { Content = item; } } // Update cell Selection bool isSelected = dataGrid.SelectedCellsInternal.Contains(this); SyncIsSelected(isSelected); } DataGridHelper.TransferProperty(this, StyleProperty); DataGridHelper.TransferProperty(this, IsReadOnlyProperty); CoerceValue(ClipProperty); }
/// <summary>Refreshes the contents of a cell in the column in response to a column property value change.</summary> /// <param name="element">The cell to update.</param> /// <param name="propertyName">The name of the column property that has changed.</param> // Token: 0x060049B6 RID: 18870 RVA: 0x0014D6C4 File Offset: 0x0014B8C4 protected internal override void RefreshCellContent(FrameworkElement element, string propertyName) { DataGridCell dataGridCell = element as DataGridCell; if (dataGridCell != null) { FrameworkElement frameworkElement = dataGridCell.Content as FrameworkElement; if (frameworkElement != null) { if (!(propertyName == "FontFamily")) { if (!(propertyName == "FontSize")) { if (!(propertyName == "FontStyle")) { if (!(propertyName == "FontWeight")) { if (propertyName == "Foreground") { DataGridHelper.SyncColumnProperty(this, frameworkElement, TextElement.ForegroundProperty, DataGridTextColumn.ForegroundProperty); } } else { DataGridHelper.SyncColumnProperty(this, frameworkElement, TextElement.FontWeightProperty, DataGridTextColumn.FontWeightProperty); } } else { DataGridHelper.SyncColumnProperty(this, frameworkElement, TextElement.FontStyleProperty, DataGridTextColumn.FontStyleProperty); } } else { DataGridHelper.SyncColumnProperty(this, frameworkElement, TextElement.FontSizeProperty, DataGridTextColumn.FontSizeProperty); } } else { DataGridHelper.SyncColumnProperty(this, frameworkElement, TextElement.FontFamilyProperty, DataGridTextColumn.FontFamilyProperty); } } } base.RefreshCellContent(element, propertyName); }
// Token: 0x060046EE RID: 18158 RVA: 0x00141D94 File Offset: 0x0013FF94 private void RemoveBindingExpressions(BindingGroup bindingGroup, DependencyObject element) { if (element == null) { return; } Collection <BindingExpressionBase> bindingExpressions = bindingGroup.BindingExpressions; BindingExpressionBase[] array = new BindingExpressionBase[bindingExpressions.Count]; bindingExpressions.CopyTo(array, 0); for (int i = 0; i < array.Length; i++) { if (DataGridHelper.BindingExpressionBelongsToElement <DataGridCell>(array[i], this)) { bindingExpressions.Remove(array[i]); } } }
// Token: 0x060048E0 RID: 18656 RVA: 0x0014AC24 File Offset: 0x00148E24 internal static bool BindingExpressionBelongsToElement <T>(BindingExpressionBase beb, T element) where T : FrameworkElement { DependencyObject targetElement = beb.TargetElement; if (targetElement != null) { DependencyObject dependencyObject = DataGridHelper.FindContextElement(beb); if (dependencyObject == null) { dependencyObject = targetElement; } if (dependencyObject is Visual || dependencyObject is Visual3D) { return(VisualTreeHelper.IsAncestorOf(element, dependencyObject, typeof(T))); } } return(false); }
// Token: 0x060046EA RID: 18154 RVA: 0x00141A5C File Offset: 0x0013FC5C internal void NotifyPropertyChanged(DependencyObject d, string propertyName, DependencyPropertyChangedEventArgs e, DataGridNotificationTarget target) { DataGridColumn dataGridColumn = d as DataGridColumn; if (dataGridColumn != null && dataGridColumn != this.Column) { return; } if (DataGridHelper.ShouldNotifyCells(target)) { if (e.Property == DataGridColumn.WidthProperty) { DataGridHelper.OnColumnWidthChanged(this, e); } else if (e.Property == DataGrid.CellStyleProperty || e.Property == DataGridColumn.CellStyleProperty || e.Property == FrameworkElement.StyleProperty) { DataGridHelper.TransferProperty(this, FrameworkElement.StyleProperty); } else if (e.Property == DataGrid.IsReadOnlyProperty || e.Property == DataGridColumn.IsReadOnlyProperty || e.Property == DataGridCell.IsReadOnlyProperty) { DataGridHelper.TransferProperty(this, DataGridCell.IsReadOnlyProperty); } else if (e.Property == DataGridColumn.DisplayIndexProperty) { base.TabIndex = dataGridColumn.DisplayIndex; } else if (e.Property == UIElement.IsKeyboardFocusWithinProperty) { base.UpdateVisualState(); } } if (DataGridHelper.ShouldRefreshCellContent(target) && dataGridColumn != null && this.NeedsVisualTree) { if (!string.IsNullOrEmpty(propertyName)) { dataGridColumn.RefreshCellContent(this, propertyName); return; } if (e.Property != null) { dataGridColumn.RefreshCellContent(this, e.Property.Name); } } }
// Token: 0x060048FB RID: 18683 RVA: 0x0014B1C0 File Offset: 0x001493C0 internal override void OnInput(InputEventArgs e) { if (DataGridHelper.HasNonEscapeCharacters(e as TextCompositionEventArgs)) { base.BeginEdit(e, true); return; } if (DataGridHelper.IsImeProcessed(e as KeyEventArgs) && base.DataGridOwner != null) { DataGridCell currentCellContainer = base.DataGridOwner.CurrentCellContainer; if (currentCellContainer != null && !currentCellContainer.IsEditing) { base.BeginEdit(e, false); base.Dispatcher.Invoke(delegate() { }, DispatcherPriority.Background); } } }
/// <summary>Draws the cell and the right side gridline.</summary> /// <param name="drawingContext">The drawing instructions for the cell.</param> // Token: 0x0600470B RID: 18187 RVA: 0x00142268 File Offset: 0x00140468 protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); DataGrid dataGridOwner = this.DataGridOwner; if (DataGridHelper.IsGridLineVisible(dataGridOwner, false)) { double verticalGridLineThickness = this.DataGridOwner.VerticalGridLineThickness; Rect rectangle = new Rect(new Size(verticalGridLineThickness, base.RenderSize.Height)); rectangle.X = base.RenderSize.Width - verticalGridLineThickness; drawingContext.DrawRectangle(this.DataGridOwner.VerticalGridLinesBrush, null, rectangle); } if (DataGridHelper.IsGridLineVisible(dataGridOwner, true)) { double horizontalGridLineThickness = dataGridOwner.HorizontalGridLineThickness; Rect rectangle2 = new Rect(new Size(base.RenderSize.Width, horizontalGridLineThickness)); rectangle2.Y = base.RenderSize.Height - horizontalGridLineThickness; drawingContext.DrawRectangle(dataGridOwner.HorizontalGridLinesBrush, null, rectangle2); } }
// Token: 0x060048DF RID: 18655 RVA: 0x0014ABA8 File Offset: 0x00148DA8 internal static bool ValidateWithoutUpdate(FrameworkElement element) { bool flag = true; BindingGroup bindingGroup = element.BindingGroup; DataGridCell dataGridCell = (element != null) ? (element.Parent as DataGridCell) : null; if (bindingGroup != null && dataGridCell != null) { Collection <BindingExpressionBase> bindingExpressions = bindingGroup.BindingExpressions; BindingExpressionBase[] array = new BindingExpressionBase[bindingExpressions.Count]; bindingExpressions.CopyTo(array, 0); foreach (BindingExpressionBase bindingExpressionBase in array) { if (DataGridHelper.BindingExpressionBelongsToElement <DataGridCell>(bindingExpressionBase, dataGridCell)) { flag = (bindingExpressionBase.ValidateWithoutUpdate() && flag); } } } return(flag); }
/// <summary> /// Creates the visual tree for cells. /// </summary> protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem) { TextBlock outerBlock = new TextBlock(); Hyperlink link = new Hyperlink(); InlineUIContainer inlineContainer = new InlineUIContainer(); ContentPresenter innerContentPresenter = new ContentPresenter(); outerBlock.Inlines.Add(link); link.Inlines.Add(inlineContainer); inlineContainer.Child = innerContentPresenter; link.TargetName = TargetName; ApplyStyle(/* isEditing = */ false, /* defaultToElementStyle = */ false, outerBlock); ApplyBinding(link, Hyperlink.NavigateUriProperty); ApplyContentBinding(innerContentPresenter, ContentPresenter.ContentProperty); DataGridHelper.RestoreFlowDirection(outerBlock, cell); return(outerBlock); }
internal override void OnInput(InputEventArgs e) { // Text input will start an edit. // Escape is meant to be for CancelEdit. But DataGrid // may not handle KeyDown event for Escape if nothing // is cancelable. Such KeyDown if unhandled by others // will ultimately get promoted to TextInput and be handled // here. But BeginEdit on escape could be confusing to the user. // Hence escape key is special case and BeginEdit is performed if // there is atleast one non espace key character. if (DataGridHelper.HasNonEscapeCharacters(e as TextCompositionEventArgs)) { BeginEdit(e, true); } else if (DataGridHelper.IsImeProcessed(e as KeyEventArgs)) { if (DataGridOwner != null) { DataGridCell cell = DataGridOwner.CurrentCellContainer; if (cell != null && !cell.IsEditing) { Debug.Assert(e.RoutedEvent == Keyboard.PreviewKeyDownEvent, "We should only reach here on the PreviewKeyDown event because the TextBox within is expected to handle the preview event and hence trump the successive KeyDown event."); BeginEdit(e, false); // // The TextEditor for the TextBox establishes contact with the IME // engine lazily at background priority. However in this case we // want to IME engine to know about the TextBox in earnest before // PostProcessing this input event. Only then will the IME key be // recorded in the TextBox. Hence the call to synchronously drain // the Dispatcher queue. // Dispatcher.Invoke((Action) delegate(){}, System.Windows.Threading.DispatcherPriority.Background); } } } }
/// <summary> /// OnRender. Overriden to draw a vertical line on the right. /// </summary> /// <param name="drawingContext"></param> protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); DataGrid dataGrid = DataGridOwner; if (DataGridHelper.IsGridLineVisible(dataGrid, /*isHorizontal = */ false)) { double thickness = DataGridOwner.VerticalGridLineThickness; Rect rect = new Rect(new Size(thickness, RenderSize.Height)); rect.X = RenderSize.Width - thickness; drawingContext.DrawRectangle(DataGridOwner.VerticalGridLinesBrush, null, rect); } if (DataGridHelper.IsGridLineVisible(dataGrid, /*isHorizontal = */ true)) { double thickness = dataGrid.HorizontalGridLineThickness; Rect rect = new Rect(new Size(RenderSize.Width, thickness)); rect.Y = RenderSize.Height - thickness; drawingContext.DrawRectangle(dataGrid.HorizontalGridLinesBrush, null, rect); } }