WinUI

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class GridCellRendererBase

    Show / Hide Table of Contents

    Class GridCellRendererBase

    Represents a class that provides default implementation of the IGridCellRenderer interface for a cell renderer. You should derive from this class to implement custom cell renderer classes. There is however no dependency on GridCellRendererBase inside the control.

    If you want to implement a renderer with support for live UIElements inside the cell you should derive from the GridVirtualizingCellRendererBase<D, E> or grid adapted to GridVirtualizingCellRendererBase classes.

    Inheritance
    System.Object
    GridCellRendererBase
    GridVirtualizingCellRendererBase<D, E>
    Implements
    IGridCellRenderer
    System.IDisposable
    Namespace: Syncfusion.UI.Xaml.DataGrid.Renderers
    Assembly: Syncfusion.Grid.WinUI.dll
    Syntax
    public class GridCellRendererBase : Object, IGridCellRenderer, IDisposable

    Constructors

    GridCellRendererBase()

    Initializes a new instance of the GridCellRendererBase class.

    Declaration
    public GridCellRendererBase()

    Properties

    BindingExpression

    Gets or sets the Microsoft.UI.Xaml.Data.BindingExpression that represents the binding for the cell.

    Declaration
    public BindingExpression BindingExpression { get; set; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.Data.BindingExpression

    The Microsoft.UI.Xaml.Data.BindingExpression that specifies the binding for the cell.

    CurrentCellElement

    Returns the element of the current cell.

    Declaration
    public FrameworkElement CurrentCellElement { get; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.FrameworkElement
    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when the current cell element is accessed before the current cell state is maintained.

    CurrentCellIndex

    Returns the RowColumnIndex of the current cell.

    Declaration
    public RowColumnIndex CurrentCellIndex { get; }
    Property Value
    Type Description
    RowColumnIndex
    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when the CurrentCellIndex is accessed before the current cell is maintained.

    CurrentCellRendererElement

    Returns the content of the current cell element.

    Declaration
    public FrameworkElement CurrentCellRendererElement { get; }
    Property Value
    Type Description
    Microsoft.UI.Xaml.FrameworkElement
    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when the renderer element of the current cell is accessed before the current cell state is maintained.

    DataGrid

    Gets or sets the reference to the SfDataGrid control.

    Declaration
    public SfDataGrid DataGrid { get; set; }
    Property Value
    Type Description
    SfDataGrid

    The reference to the SfDataGrid control.

    HasCurrentCellState

    Gets a value that indicates whether the current cell state is maintained in SfDataGrid.

    Declaration
    public bool HasCurrentCellState { get; }
    Property Value
    Type Description
    System.Boolean

    Returns true if the current cell state is maintained; otherwise , false.

    IsDropDownable

    Gets or sets a value that indicates whether the cell that contains the drop-down control.

    Declaration
    public bool IsDropDownable { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the cell is dropdownable; otherwise, false.

    IsEditable

    Gets or sets a value that indicates whether the current cell is editable or not.

    Declaration
    public bool IsEditable { get; set; }
    Property Value
    Type Description
    System.Boolean

    true the current cell is editable; otherwise ,false.

    IsFocused

    Gets or sets a value that indicates whether the current cell is focused or not.

    Declaration
    public bool IsFocused { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the current cell is focused; otherwise , false.

    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when the cell is focused before the current cell state is maintained.

    IsFocusible

    Gets or sets a value that indicates whether the cell is focusable.

    Declaration
    public bool IsFocusible { get; set; }
    Property Value
    Type Description
    System.Boolean

    true the current cell is focusable; otherwise ,false.

    IsInEditing

    Returns the current cell is in editing or not.

    Declaration
    public bool IsInEditing { get; set; }
    Property Value
    Type Description
    System.Boolean
    Exceptions
    Type Condition
    System.InvalidOperationException

    Thrown when the current cell is edited before the current cell state is maintained.

    PreviewInputText

    Gets or sets the input text for the Renderer.

    Declaration
    protected string PreviewInputText { get; set; }
    Property Value
    Type Description
    System.String

    The preview input text for the renderer.

    SupportsRenderOptimization

    Gets or sets a value that indicates whether the renderer supports rendering itself directly to the drawing context.

    Declaration
    public bool SupportsRenderOptimization { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the renderer supports directly to the drawing context ; otherwise, false.

    UseOnlyRendererElement

    Gets or sets a value that indicates whether the grid cell is placed inside the renderer element.

    Declaration
    public bool UseOnlyRendererElement { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the grid cell is placed inside the renderer element; otherwise, false.

    Methods

    Arrange(RowColumnIndex, FrameworkElement, Rect)

    Invoked when the visual children of cell is arranged in view.

    Declaration
    public void Arrange(RowColumnIndex cellRowColumnIndex, FrameworkElement uiElement, Rect cellRect)
    Parameters
    Type Name Description
    RowColumnIndex cellRowColumnIndex

    The corresponding row and column index of the cell.

    Microsoft.UI.Xaml.FrameworkElement uiElement

    The corresponding UiElement that is to be arranged

    Windows.Foundation.Rect cellRect

    The corresponding size of cell element for arranging the UIElement

    BeginEdit(RowColumnIndex, FrameworkElement, GridColumn, Object)

    Starts an edit operation on a current cell.

    Declaration
    public virtual bool BeginEdit(RowColumnIndex cellRowColumnIndex, FrameworkElement cellElement, GridColumn column, object record)
    Parameters
    Type Name Description
    RowColumnIndex cellRowColumnIndex

    Specifies the row and column index of the cell to start an edit operation.

    Microsoft.UI.Xaml.FrameworkElement cellElement

    Specifies the UIElement of the cell to start an edit operation.

    GridColumn column

    The corresponding column to edit the cell.

    System.Object record

    The corresponding record to edit the cell.

    Returns
    Type Description
    System.Boolean

    Returns true if the current cell starts an editing; otherwise, false.

    CanUpdateBinding(GridColumn)

    Determines whether the binding for the column can be updated. Implement this method to update binding on particular renderer when the data context is set.

    Declaration
    public virtual bool CanUpdateBinding(GridColumn column)
    Parameters
    Type Name Description
    GridColumn column

    Specifies the corresponding GridColumn.

    Returns
    Type Description
    System.Boolean

    Returns true if the binding is updated for the column.

    CanValidate()

    Determines whether the cell validation is allowed. Implement this method to allow cell validation in particular renderer.

    Declaration
    public virtual bool CanValidate()
    Returns
    Type Description
    System.Boolean

    Returns true if the cell validation is allowed.

    ClearRecycleBin()

    Clears the recycle bin.

    Declaration
    public virtual void ClearRecycleBin()

    CommitUnboundCellValue(Object, GridColumn, Object)

    Commits the changes in the unbound cell where the renderer doesn't support value changed event.

    Declaration
    public void CommitUnboundCellValue(object record, GridColumn column, object value)
    Parameters
    Type Name Description
    System.Object record

    Specifies the corresponding record to commit the cell value.

    GridColumn column

    Specifies the corresponding column to commit the cell value.

    System.Object value

    Specifies the cell value to commit it.

    Dispose()

    Releases all resources used by the GridCellRendererBase class.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Disposes all the resources used by the GridCellRendererBase class.

    Declaration
    protected virtual void Dispose(bool isDisposing)
    Parameters
    Type Name Description
    System.Boolean isDisposing

    Indicates whether the call is from Dispose method or from a finalizer.

    EndEdit(DataColumnBase, Object, Boolean)

    Ends the edit occurring on the cell.

    Declaration
    public virtual bool EndEdit(DataColumnBase dc, object record, bool canResetBinding = false)
    Parameters
    Type Name Description
    DataColumnBase dc

    Specifies the corresponding DataColumnBase to complete the edit operation.

    System.Object record

    The corresponding record to complete the edit operation.

    System.Boolean canResetBinding

    Specifies whether the binding is reset or not.

    Returns
    Type Description
    System.Boolean

    Returns true if the editing is completed ; otherwise, false.

    GetControlValue()

    Gets the control value of the cell.

    Declaration
    public virtual object GetControlValue()
    Returns
    Type Description
    System.Object

    Returns the control value as null by default .

    Measure(RowColumnIndex, FrameworkElement, Size)

    Invoked when the desired size for cell is measured.

    Declaration
    public void Measure(RowColumnIndex cellRowColumnIndex, FrameworkElement uiElement, Size availableSize)
    Parameters
    Type Name Description
    RowColumnIndex cellRowColumnIndex

    The corresponding row and column index of the cell

    Microsoft.UI.Xaml.FrameworkElement uiElement

    Specifies the corresponding UiElement to measure.

    Windows.Foundation.Size availableSize

    The available size that a parent element can allocate the cell.

    OnArrange(RowColumnIndex, FrameworkElement, Rect)

    Invoked when the visual children of cell is arranged in view.

    Declaration
    protected virtual void OnArrange(RowColumnIndex cellRowColumnIndex, FrameworkElement uiElement, Rect cellRect)
    Parameters
    Type Name Description
    RowColumnIndex cellRowColumnIndex

    The corresponding row and column index of the cell.

    Microsoft.UI.Xaml.FrameworkElement uiElement

    The corresponding UiElement that is to be arranged

    Windows.Foundation.Rect cellRect

    The corresponding size of cell element for arranging the UIElement

    OnMeasure(RowColumnIndex, FrameworkElement, Size)

    Invoked when the desired size for cell is measured.

    Declaration
    protected virtual void OnMeasure(RowColumnIndex cellRowColumnIndex, FrameworkElement uiElement, Size availableSize)
    Parameters
    Type Name Description
    RowColumnIndex cellRowColumnIndex

    The corresponding row and column index of the cell

    Microsoft.UI.Xaml.FrameworkElement uiElement

    Specifies the corresponding UiElement to measure.

    Windows.Foundation.Size availableSize

    The available size that a parent element can allocate the cell.

    OnPrepareUIElements()

    Invoked when the cell elements are prepared for rendering in view .

    Declaration
    protected virtual FrameworkElement OnPrepareUIElements()
    Returns
    Type Description
    Microsoft.UI.Xaml.FrameworkElement

    Returns the new cell UIElement.

    OnPrepareUIElements(DataColumnBase, Object, Boolean)

    Invoked when the UIElement for cell is prepared to render it in view . GridVirtualizingCellRendererBase<D, E> overrides this method and creates new UIElements and wires them with the parent cells control.

    Declaration
    protected virtual FrameworkElement OnPrepareUIElements(DataColumnBase dataColumn, object record, bool isInEdit)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    The corresponding column of the element.

    System.Object record

    The corresponding Record for the element.

    System.Boolean isInEdit

    Specifies whether the element is editable or not.

    Returns
    Type Description
    Microsoft.UI.Xaml.FrameworkElement

    Returns the new cell UIElement.

    OnPreviewTextInput(KeyRoutedEventArgs)

    Invoked when an unhanded PreviewTextInput attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

    Declaration
    protected virtual void OnPreviewTextInput(KeyRoutedEventArgs e)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e

    The Microsoft.UI.Xaml.Input.KeyRoutedEventArgs that contains the event data.

    OnUnloadUIElements(DataColumnBase)

    Invoked when the cell is scrolled out of view or unloaded from the view. GridVirtualizingCellRendererBase<D,E> class overrides this method to remove the cell renderer visuals from the parent or hide them to reuse it later in same element depending on whether GridVirtualizingCellRendererBase < D,E >.AllowRecycle was set.

    Declaration
    protected virtual void OnUnloadUIElements(DataColumnBase dataColumn)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    Specifies the column to unload the cell UIElement.

    OnUpdateBindingInfo(DataColumnBase, Object, Boolean)

    Updates the binding of the Cell UIElement for the specified column. Implement this method to update binding when the cell UIElement is reused during horizontal scrolling.

    Declaration
    protected virtual void OnUpdateBindingInfo(DataColumnBase dataColumn, object record, bool isInEdit)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    Specifies the corresponding column to update binding.

    System.Object record

    The corresponding record to update binding.

    System.Boolean isInEdit

    Indicates whether the cell is editable or not.

    OnUpdateStyleInfo(DataColumnBase, Object)

    Updates the style for the particular column. Implement this method to update style when the cell UIElement is reused during scrolling.

    Declaration
    protected virtual void OnUpdateStyleInfo(DataColumnBase dataColumn, object dataContext)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    Specifies the corresponding column to update style.

    System.Object dataContext

    Specifies the data context.

    PrepareUIElements(DataColumnBase, Object, Boolean)

    Invoked when the UIElement for cell is prepared to render it in view . GridVirtualizingCellRendererBase<D, E> overrides this method and creates new UIElements and wires them with the parent cells control.

    Declaration
    public FrameworkElement PrepareUIElements(DataColumnBase dataColumn, object record, bool isInEdit)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    The corresponding column of the element.

    System.Object record

    The corresponding Record for the element.

    System.Boolean isInEdit

    Specifies whether the element is editable or not.

    Returns
    Type Description
    Microsoft.UI.Xaml.FrameworkElement

    Returns the new cell UIElement.

    PreviewTextInput(KeyRoutedEventArgs)

    Invoked when an unhanded PreviewTextInput attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

    Declaration
    public void PreviewTextInput(KeyRoutedEventArgs args)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.Input.KeyRoutedEventArgs args

    The Microsoft.UI.Xaml.Input.KeyRoutedEventArgs that contains the event data.

    ResetCurrentCellState()

    Resets the state of current cell when the cell is deactivated.

    Declaration
    public void ResetCurrentCellState()

    SetControlValue(Object)

    Sets the control value of the cell.

    Declaration
    public virtual void SetControlValue(object value)
    Parameters
    Type Name Description
    System.Object value

    Specifies the value to set the control value of the cell.

    SetCurrentCellState(RowColumnIndex, FrameworkElement, Boolean, Boolean, GridColumn, DataColumnBase)

    Sets the current cell state when the cell is activated.

    Declaration
    public virtual void SetCurrentCellState(RowColumnIndex currentCellIndex, FrameworkElement currentCellElement, bool isInEditing, bool isFocused, GridColumn column, DataColumnBase dc)
    Parameters
    Type Name Description
    RowColumnIndex currentCellIndex

    Specifies the index of cell.

    Microsoft.UI.Xaml.FrameworkElement currentCellElement

    The corresponding current cell uielement.

    System.Boolean isInEditing

    Specifies whether the current cell is editable or not.

    System.Boolean isFocused

    Specifies whether the current cell is focused or not.

    GridColumn column

    The corresponding column to set the current cell state.

    DataColumnBase dc

    The corresponding data column to set the current cell state.

    SetFocus(FrameworkElement, Boolean)

    Sets the focus to the specified current cell uielement.

    Declaration
    protected virtual void SetFocus(FrameworkElement uiElement, bool needToFocus)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.FrameworkElement uiElement

    Specifies the corresponding current cell uielement.

    System.Boolean needToFocus

    Decides whether the focus set to current cell uielement.

    SetFocus(Boolean)

    Sets the focus to the current cell renderer element.

    Declaration
    public void SetFocus(bool setFocus)
    Parameters
    Type Name Description
    System.Boolean setFocus

    Specifies whether the current cell renderer element is focusable or not.

    ShouldGridTryToHandleKeyDown(KeyRoutedEventArgs)

    Decides whether the parent grid should allowed to handle keys and prevent the key event from being handled by the visual UIElement for this renderer.

    Declaration
    protected virtual bool ShouldGridTryToHandleKeyDown(KeyRoutedEventArgs e)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e

    A Microsoft.UI.Xaml.Input.KeyRoutedEventArgs that contains event data.

    Returns
    Type Description
    System.Boolean

    Returns true if the parent grid should be allowed to handle keys; otherwise false.

    UnloadUIElements(DataColumnBase)

    Invoked when the cell is scrolled out of view or unloaded from the view. GridVirtualizingCellRendererBase<D, E> class overrides this method to remove the cell renderer visuals from the parent or hide them to reuse it later in same element depending on whether AllowRecycle was set.

    Declaration
    public void UnloadUIElements(DataColumnBase dataColumn)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    Specifies the column to unload the cell UIElement.

    UpdateBindingInfo(DataColumnBase, Object, Boolean)

    Invoked to update the Binding information of the Cell UIElement for the Specified column.

    Declaration
    protected void UpdateBindingInfo(DataColumnBase dataColumn, object record, bool isInEdit)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    The corresponding column.

    System.Object record

    The record.

    System.Boolean isInEdit

    Indicates whether the current cell is in editing or not.

    UpdateCellStyle(DataColumnBase, Object)

    Updates the cell style of the particular column. Implement this method to update style when the cell UIElement is reused during scrolling.

    Declaration
    public void UpdateCellStyle(DataColumnBase dataColumn, object dataContext)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    Specifies the corresponding column to update style.

    System.Object dataContext

    Specifies the data context.

    UpdateCurrentCellState(FrameworkElement, Boolean)

    Updates the current cell state for the specified current cell renderer element.

    Declaration
    protected void UpdateCurrentCellState(FrameworkElement currentRendererElement, bool isInEdit)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.FrameworkElement currentRendererElement

    Specifies the current cell uielement to update the current cell state.

    System.Boolean isInEdit

    Specifies whether the current cell is editable.

    UpdateSource(FrameworkElement)

    Updates the current binding target value to the binding source property in TwoWay or OneWayToSource bindings.

    Declaration
    public virtual void UpdateSource(FrameworkElement cellElement)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.FrameworkElement cellElement

    Specifies the corresponding cell element to update binding.

    UpdateToolTip(DataColumnBase)

    Updates the tool tip for the specified column.

    Declaration
    public virtual void UpdateToolTip(DataColumnBase dataColumn)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    Specifies the column to update tool tip.

    Explicit Interface Implementations

    IGridCellRenderer.ShouldGridTryToHandleKeyDown(KeyRoutedEventArgs)

    Decides whether the parent grid should allowed to handle keys and prevent the key event from being handled by the visual UIElement for this renderer.

    Declaration
    bool IGridCellRenderer.ShouldGridTryToHandleKeyDown(KeyRoutedEventArgs e)
    Parameters
    Type Name Description
    Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e

    A Microsoft.UI.Xaml.Input.KeyRoutedEventArgs that contains event data.

    Returns
    Type Description
    System.Boolean

    true if the parent grid should be allowed to handle keys; otherwise false.

    IGridCellRenderer.UpdateBindingInfo(DataColumnBase, Object, Boolean)

    Updates the binding of the Cell UIElement for the specified column. Implement this method to update binding when the cell UIElement is reused during horizontal scrolling.

    Declaration
    void IGridCellRenderer.UpdateBindingInfo(DataColumnBase dataColumn, object record, bool isInEdit)
    Parameters
    Type Name Description
    DataColumnBase dataColumn

    Specifies the corresponding column to update binding.

    System.Object record

    The corresponding record to update binding.

    System.Boolean isInEdit

    Indicates whether the cell is editable or not.

    Implements

    IGridCellRenderer
    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved