Class VirtualizingCellRendererBase<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 SupportsRenderOptimization is true the UIElement will only be created when the user moves the mouse over the cell or if the UIElement is needed for other reasons.
After a UIElement was created the virtual methods Syncfusion.Windows.Controls.Cells.VirtualizingCellRendererBase`1.WireUIElement(`0) and Syncfusion.Windows.Controls.Cells.VirtualizingCellRendererBase`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.Cells
Assembly: Syncfusion.GridCommon.WPF.dll
Syntax
public abstract class VirtualizingCellRendererBase<T> : CellRendererBase<IRenderCellInfo>, ICellRenderer, IDisposable where T : FrameworkElement, new()
Type Parameters
Name | Description |
---|---|
T | The type of the UIElement that should be placed inside cells |
Constructors
VirtualizingCellRendererBase()
Declaration
protected VirtualizingCellRendererBase()
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
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 |
|
SupportsRenderOptimization
Gets or sets whether the renderer supports rendering itsself directly to the drawing context. When this is possible the UIElement will only be created when the user moves the mouse over the cell or if the UIElement is needed for other reasons, e.g. animate after change. The benefit of rendering directly to the DrawingContext instead of creating the UIElement is a much improved scrolling performance. The default value is false.
Declaration
public bool SupportsRenderOptimization { get; set; }
Property Value
Type |
---|
System.Boolean |
Methods
ArrangeUIElement(ArrangeCellArgs, T, IRenderCellInfo)
Arranges the 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 virtual void ArrangeUIElement(ArrangeCellArgs aca, T uiElement, IRenderCellInfo style)
Parameters
Type | Name | Description |
---|---|---|
ArrangeCellArgs | aca | The arrange cell layout. |
T | uiElement | The UI element. |
IRenderCellInfo | style | The cell style. |
CreateUIElement(ArrangeCellArgs, IRenderCellInfo)
Creates a new UIElement of type specified with the class type parameter.
Declaration
protected virtual T CreateUIElement(ArrangeCellArgs aca, IRenderCellInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
ArrangeCellArgs | aca | |
IRenderCellInfo | cellInfo |
Returns
Type |
---|
T |
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 |
---|
T |
InitializeContent(T, IRenderCellInfo)
Called from OnArrange(ArrangeCellArgs, IRenderCellInfo) 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, IRenderCellInfo) which you should override in your derived class.
Declaration
public void InitializeContent(T uiElement, IRenderCellInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
T | uiElement | The UI element. |
IRenderCellInfo | 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 |
OnArrange(ArrangeCellArgs, IRenderCellInfo)
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, IRenderCellInfo). The UIElement is arranged on the canvas with a call to ArrangeUIElement(ArrangeCellArgs, T, IRenderCellInfo).
Declaration
protected override void OnArrange(ArrangeCellArgs aca, IRenderCellInfo style)
Parameters
Type | Name | Description |
---|---|---|
ArrangeCellArgs | aca | The arange cell layout information. |
IRenderCellInfo | 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, IRenderCellInfo)
Called to initialize the content of the cell 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, IRenderCellInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
T | uiElement | The UI element. |
IRenderCellInfo | cellInfo | The cell style info. |
OnPrepareUIElements(ArrangeCellArgs, List<UIElement>, ScrollControlChildFrame, IRenderCellInfo)
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, IRenderCellInfo 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. |
IRenderCellInfo | 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 |