Class GridVirtualizingCellRendererBase<T>
VirtualizingCellRendererBase is an abstract base class for cell renderers that need live UIElement visuals displayed in a cell. You can derive from this class and provide the type of the UIElement you want to show inside cells as type parameter. The class provides strong typed virtual methods for initializing content of the cell and arranging the cell visuals.
The class manages the creation of cells UIElement objects when the cell is scrolled into view and also unloading of the elements. The class offers an optimization in which elements can be recycled when AllowRecycle is set. In this case when a cell is scrolled out of view it is moved into a recycle bin and the next time a new element is scrolled into view the element is recovered from the recycle bin and reinitialized with the new content of the cell.
Another optimization is support for cells rendering themselves directly to the
drawing context. When
After a UIElement was created the virtual methods Syncfusion.Windows.Controls.Grid.GridVirtualizingCellRendererBase`1.WireUIElement(`0) and Syncfusion.Windows.Controls.Grid.GridVirtualizingCellRendererBase`1.UnwireUIElement(`0) are called to wire any event listeners.
Updates to appearance and content of child elements, creation and unloading of elements will not trigger ArrangeOverride or Render calls in parent canvas.
In Grid and Tree control you should not derive from this class. Instead you should derive from the GridVirtualizingCellRendererBase and TreeVirtualizingCellRendererBase classes. These classes are the exact same code base as this class with the only difference that they derive from GridCellRendererBase and TreeCellRenderer base classes instead. It is currently not possible with C# to the base class as template type parameter. This is the reason for this copy/paste approach for the codebase of this class.
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Controls.Grid
Assembly: Syncfusion.Grid.Wpf.dll
Syntax
public abstract class GridVirtualizingCellRendererBase<T> : GridCellRendererBase, IGridCellRenderer, ICellRenderer, IHitTestSelectCells, IStyleChanged, IDisposable where T : FrameworkElement, new()
Type Parameters
Name | Description |
---|---|
T | The type of the UIElement that should be placed inside cells |
Constructors
GridVirtualizingCellRendererBase()
Declaration
protected GridVirtualizingCellRendererBase()
Properties
AllowRecycle
Gets or sets a value indicating whether elements can be recycled when scrolled out of view. In this case when a cell is scrolled out of view it is moved into a recycle bin and the next time a new element is scrolled into view the element is recovered from the recycle bin and reinitialized with the new content of the cell. The default value is false.
Declaration
public bool AllowRecycle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
AllowRecycleIfIsKeyboardFocusWithin
When true, it allows to recycle the UI element if it contains the keyboard focus.
Declaration
public bool AllowRecycleIfIsKeyboardFocusWithin { get; set; }
Property Value
Type |
---|
System.Boolean |
AllowTransparentBackground
Gets or sets a value indicating whether the background of the UIElement visual placed in the cell can be set to System.Windows.Media.Brushes.Transparent. This is needed in order for the cells control to draw the cell background color behind the UIElement. The default value is true.
Declaration
public bool AllowTransparentBackground { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
InInitializeContent
Gets a value indicating whether InitializeContent was called.
Declaration
public bool InInitializeContent { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
ArrangeUIElement(ArrangeCellArgs, T, GridRenderStyleInfo)
Arranges the UI element inside the cell rectangle.
Declaration
protected virtual void ArrangeUIElement(ArrangeCellArgs aca, T uiElement, GridRenderStyleInfo style)
Parameters
Type | Name | Description |
---|---|---|
ArrangeCellArgs | aca | The arrange cell layout. |
T | uiElement | The UI element. |
GridRenderStyleInfo | style | The cell style. |
CreateRendererElement(T, GridRenderStyleInfo)
Called to initialize the content of the cell when using the information from the cell style (value, text, behavior etc.). You must override this method in your derived class.
Declaration
public abstract void CreateRendererElement(T uiElement, GridRenderStyleInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
T | uiElement | The UI element. |
GridRenderStyleInfo | cellInfo | The cell style info. |
CreateUIElement(ArrangeCellArgs, GridRenderStyleInfo)
Creates a new UIElement of type specified with the class type parameter.
Declaration
protected virtual T CreateUIElement(ArrangeCellArgs aca, GridRenderStyleInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
ArrangeCellArgs | aca | |
GridRenderStyleInfo | cellInfo |
Returns
Type | Description |
---|---|
T | The UI element. |
Dispose(Boolean)
This gets called when parent grid is unloaded. Unload all elements that were saved for later reuse.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
GetBounds(UIElement)
Declaration
public static Rect GetBounds(UIElement el)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.UIElement | el |
Returns
Type |
---|
System.Windows.Rect |
GetUIElement(CellUIElements)
Gets the UI element or null if the cell visuals do not have any UIElement visuals.
Declaration
public T GetUIElement(CellUIElements cellUIElements)
Parameters
Type | Name | Description |
---|---|---|
CellUIElements | cellUIElements | The cell visuals. |
Returns
Type | Description |
---|---|
T | The UI element. |
InitializeContent(T, GridRenderStyleInfo)
Called from OnArrange(ArrangeCellArgs, GridRenderStyleInfo) to initialize the content of the cell using the information from the cell style (value, text, behavior etc.). The method calls the virtual OnInitializeContent(T, GridRenderStyleInfo) which you should override in your derived class.
Declaration
public void InitializeContent(T uiElement, GridRenderStyleInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
T | uiElement | The UI element. |
GridRenderStyleInfo | cellInfo | The cell style info. |
InitializeDefaultProperties(T)
Set Backgrounds, BorderThickness, Padding and IsEnabled properties.
Declaration
protected virtual void InitializeDefaultProperties(T uiElement)
Parameters
Type | Name | Description |
---|---|---|
T | uiElement | The UI element. |
InvalidateMeasureRecursive(UIElement)
Declaration
protected void InvalidateMeasureRecursive(UIElement obj)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.UIElement | obj |
OnArrange(ArrangeCellArgs, GridRenderStyleInfo)
Called from Arrange(ArrangeCellArgs) to arrange the cells UIElement children. The method checks ShouldCreateVisuals and if this is true it will initialize the newly created UIElement with attached properties about CellRowColumnIndex, RenderCellInfo, CellRenderer, initialize its default properties with a call to InitializeDefaultProperties(T) and its cell specific content with a call to InitializeContent(T, GridRenderStyleInfo). The UIElement is arranged on the canvas with a call to ArrangeUIElement(ArrangeCellArgs, T, GridRenderStyleInfo).
Declaration
protected override void OnArrange(ArrangeCellArgs aca, GridRenderStyleInfo style)
Parameters
Type | Name | Description |
---|---|---|
ArrangeCellArgs | aca | The arange cell layout information. |
GridRenderStyleInfo | style | The cell style info. |
Overrides
OnElementArranged(UIElement, Rect)
Declaration
protected virtual void OnElementArranged(UIElement el, Rect rect)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.UIElement | el | |
System.Windows.Rect | rect |
OnElementMeasured(UIElement, Size)
Declaration
protected virtual void OnElementMeasured(UIElement el, Size size)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.UIElement | el | |
System.Windows.Size | size |
OnInitializeContent(T, GridRenderStyleInfo)
Called to initialize the content of the cell when in edit using the information from the cell style (value, text, behavior etc.). You must override this method in your derived class.
Declaration
public abstract void OnInitializeContent(T uiElement, GridRenderStyleInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
T | uiElement | The UI element. |
GridRenderStyleInfo | cellInfo | The cell style info. |
OnPrepareUIElements(ArrangeCellArgs, List<UIElement>, ScrollControlChildFrame, GridRenderStyleInfo)
Called from Arrange(ArrangeCellArgs) to prepare the cells UIElement children. VirtualizingCellRendererBase overrides this method and creates new UIElements and wires them with the parent cells control.
Declaration
protected override void OnPrepareUIElements(ArrangeCellArgs aca, List<UIElement> uiElements, ScrollControlChildFrame canvas, GridRenderStyleInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
ArrangeCellArgs | aca | The arange cell layout information. |
System.Collections.Generic.List<System.Windows.UIElement> | uiElements | The UI elements. |
ScrollControlChildFrame | canvas | The canvas to which any UIElement elements should be added. |
GridRenderStyleInfo | cellInfo | The cell style info. |
Overrides
OnUnloadUIElements(VirtualizingCellsControl, RowColumnIndex, CellUIElements)
Called from UnloadUIElements(VirtualizingCellsControl, RowColumnIndex, CellUIElements) after a cell is scrolled out of view. VirtualizingCellRendererBase overrides this method and creates either removes the cell renderer visuals from the parent canvas or hide them and reuse it later in same canvas depending on whether AllowRecycle was set.
Declaration
protected override sealed void OnUnloadUIElements(VirtualizingCellsControl host, RowColumnIndex cellRowColumnIndex, CellUIElements visuals)
Parameters
Type | Name | Description |
---|---|---|
VirtualizingCellsControl | host | The host. |
RowColumnIndex | cellRowColumnIndex | Index of the cell row column. |
CellUIElements | visuals | The visuals. |
Overrides
OnUnwireUIElement(T)
Unwire previously wired events from uiElement.
Declaration
protected virtual void OnUnwireUIElement(T uiElement)
Parameters
Type | Name | Description |
---|---|---|
T | uiElement |
OnWireUIElement(T)
Wire events from uiElement
Declaration
protected virtual void OnWireUIElement(T uiElement)
Parameters
Type | Name | Description |
---|---|---|
T | uiElement |
SetBounds(UIElement, Rect)
Helper method which arranges an UI element by setting the Left, Top, Right, Bottom attached properties and its Width, Height, MaxWidth and MaxHeight properties. The visibility is set to Visibility.Visible and the elements Measure and Arrange methods are called.
Declaration
protected void SetBounds(UIElement el, Rect rect)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.UIElement | el | The element. |
System.Windows.Rect | rect | The rectangle. |
SetBounds(UIElement, Rect, Boolean, Boolean)
Helper method which arranges an UI element by setting the Left, Top, Right, Bottom attached properties and its Width, Height, MaxWidth and MaxHeight properties. The visibility is set to Visibility.Visible and the elements Measure and Arrange methods are called.
Declaration
protected void SetBounds(UIElement el, Rect rect, bool forceMeasure, bool forceArrange)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.UIElement | el | The element. |
System.Windows.Rect | rect | The rectangle. |
System.Boolean | forceMeasure | |
System.Boolean | forceArrange |