WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class TreeVirtualizingCellRendererBase<T>

    Show / Hide Table of Contents

    Class TreeVirtualizingCellRendererBase<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.VirtualTreeView.TreeVirtualizingCellRendererBase`1.WireUIElement(`0) and Syncfusion.Windows.Controls.VirtualTreeView.TreeVirtualizingCellRendererBase`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
    System.Object
    NonFinalizeDisposable
    Disposable
    CellRendererBase<TreeRenderStyleInfo>
    Syncfusion.Windows.Controls.VirtualTreeView.TreeCellRenderer
    TreeVirtualizingCellRendererBase<T>
    TreeVirtualizingCellRenderer<T>
    Implements
    ICellRenderer
    System.IDisposable
    Inherited Members
    CellRendererBase<TreeRenderStyleInfo>.isInArrange
    CellRendererBase<TreeRenderStyleInfo>.OnRender(DrawingContext, RenderCellArgs, TreeRenderStyleInfo)
    CellRendererBase<TreeRenderStyleInfo>.ICellRenderer.Render(DrawingContext, RenderCellArgs)
    CellRendererBase<TreeRenderStyleInfo>.ICellRenderer.Arrange(ArrangeCellArgs)
    CellRendererBase<TreeRenderStyleInfo>.ICellRenderer.PrepareUIElements(ArrangeCellArgs, List<UIElement>, ScrollControlChildFrame)
    CellRendererBase<TreeRenderStyleInfo>.ICellRenderer.UnloadUIElements(VirtualizingCellsControl, RowColumnIndex, CellUIElements)
    CellRendererBase<TreeRenderStyleInfo>.ICellRenderer.CancelMouseCapture(UIElement)
    CellRendererBase<TreeRenderStyleInfo>.OnCancelMouseCapture(UIElement)
    CellRendererBase<TreeRenderStyleInfo>.ICellRenderer.RecaptureMouse(UIElement)
    CellRendererBase<TreeRenderStyleInfo>.OnRecaptureMouse(UIElement)
    CellRendererBase<TreeRenderStyleInfo>.RefreshCellUIElementsContent(VirtualizingCellsControl, CellUIElements, RowColumnIndex)
    CellRendererBase<TreeRenderStyleInfo>.Hide(UIElement)
    CellRendererBase<TreeRenderStyleInfo>.IsInArrange
    CellRendererBase<TreeRenderStyleInfo>.AllowCancelMouseCapture
    CellRendererBase<TreeRenderStyleInfo>.ICellRenderer.UnloadUIElementsWhenScrolledOutOfView
    CellRendererBase<TreeRenderStyleInfo>.UnloadVisualsWhenScrolledOutOfView
    NonFinalizeDisposable.Dispose()
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Syncfusion.Windows.Controls.VirtualTreeView
    Assembly: Syncfusion.GridCommon.Wpf.dll
    Syntax
    public abstract class TreeVirtualizingCellRendererBase<T> : TreeCellRenderer, ICellRenderer, IDisposable where T : FrameworkElement, new()
    Type Parameters
    Name Description
    T

    The type of the UIElement that should be placed inside cells

    Constructors

    TreeVirtualizingCellRendererBase()

    Declaration
    protected TreeVirtualizingCellRendererBase()

    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

    true if elements can be recycled when scrolled out of view; otherwise, false.

    AllowRecycleIfIsKeyboardFocusWithin

    Declaration
    public bool AllowRecycleIfIsKeyboardFocusWithin { get; set; }
    Property Value
    Type Description
    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

    true if [allow transparent background]; otherwise, false.

    InInitializeContent

    Gets a value indicating whether InitializeContent was called.

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

    true if InitializeContent was called; otherwise, false.

    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 Description
    System.Boolean

    Methods

    ArrangeUIElement(ArrangeCellArgs, T, TreeRenderStyleInfo)

    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, TreeRenderStyleInfo style)
    Parameters
    Type Name Description
    ArrangeCellArgs aca

    The arrange cell layout.

    T uiElement

    The UI element.

    TreeRenderStyleInfo style

    The cell style.

    CreateUIElement(ArrangeCellArgs, TreeRenderStyleInfo)

    Creates a new UIElement of type specified with the class type parameter.

    Declaration
    protected virtual T CreateUIElement(ArrangeCellArgs aca, TreeRenderStyleInfo cellInfo)
    Parameters
    Type Name Description
    ArrangeCellArgs aca
    TreeRenderStyleInfo cellInfo
    Returns
    Type Description
    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
    NonFinalizeDisposable.Dispose(Boolean)

    GetBounds(UIElement)

    Declaration
    public static Rect GetBounds(UIElement el)
    Parameters
    Type Name Description
    System.Windows.UIElement el
    Returns
    Type Description
    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

    InitializeContent(T, TreeRenderStyleInfo)

    Called from OnArrange(ArrangeCellArgs, TreeRenderStyleInfo) 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, TreeRenderStyleInfo) which you should override in your derived class.

    Declaration
    public void InitializeContent(T uiElement, TreeRenderStyleInfo cellInfo)
    Parameters
    Type Name Description
    T uiElement

    The UI element.

    TreeRenderStyleInfo 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, TreeRenderStyleInfo)

    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, TreeRenderStyleInfo). The UIElement is arranged on the canvas with a call to ArrangeUIElement(ArrangeCellArgs, T, TreeRenderStyleInfo).

    Declaration
    protected override void OnArrange(ArrangeCellArgs aca, TreeRenderStyleInfo style)
    Parameters
    Type Name Description
    ArrangeCellArgs aca

    The arange cell layout information.

    TreeRenderStyleInfo style

    The cell style info.

    Overrides
    Syncfusion.Windows.Controls.Cells.CellRendererBase<Syncfusion.Windows.Controls.VirtualTreeView.TreeRenderStyleInfo>.OnArrange(Syncfusion.Windows.Controls.Cells.ArrangeCellArgs, Syncfusion.Windows.Controls.VirtualTreeView.TreeRenderStyleInfo)

    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, TreeRenderStyleInfo)

    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, TreeRenderStyleInfo cellInfo)
    Parameters
    Type Name Description
    T uiElement

    The UI element.

    TreeRenderStyleInfo cellInfo

    The cell style info.

    OnPrepareUIElements(ArrangeCellArgs, List<UIElement>, ScrollControlChildFrame, TreeRenderStyleInfo)

    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, TreeRenderStyleInfo 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.

    TreeRenderStyleInfo cellInfo

    The cell style info.

    Overrides
    Syncfusion.Windows.Controls.Cells.CellRendererBase<Syncfusion.Windows.Controls.VirtualTreeView.TreeRenderStyleInfo>.OnPrepareUIElements(Syncfusion.Windows.Controls.Cells.ArrangeCellArgs, System.Collections.Generic.List<System.Windows.UIElement>, Syncfusion.Windows.Controls.Scroll.ScrollControlChildFrame, Syncfusion.Windows.Controls.VirtualTreeView.TreeRenderStyleInfo)

    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
    Syncfusion.Windows.Controls.Cells.CellRendererBase<Syncfusion.Windows.Controls.VirtualTreeView.TreeRenderStyleInfo>.OnUnloadUIElements(Syncfusion.Windows.Controls.Cells.VirtualizingCellsControl, Syncfusion.Windows.Controls.Cells.RowColumnIndex, Syncfusion.Windows.Controls.Cells.CellUIElements)

    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

    Implements

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