Class VirtualTreeView
The VirtualTreeView displays a hierarchical collection of expandable TreeNode items maintained by a TreeModel. A flattened representations of the hierarchy of nodes can be accessed through the VisibleNodes property of the Model where each visible node is mapped to a row index and vice versa. TreeNodesFlattenedList also implements ILineSizeHost and the VirtualTreeView assigns it to RowHeightsProvider in order to be able to pixel scroll through visible and expanded nodes.
VirtualTreeView returns cell contents with the GetRenderStyleInfo(RowColumnIndex) method which returns a TreeRenderStyleInfo object. Each cell is associated with a Syncfusion.Windows.Controls.VirtualTreeView.TreeCellRenderer object which provides methods for measuring, arranging and drawing contents of a cell. The VirtualTreeView implements the OnArrangeContent(Size) and System.Windows.UIElement.OnRender(System.Windows.Media.DrawingContext) methods. Within implementation of the OnArrangeContent method each cells UIElement children are placed on the controls area. A cell renderer can also be without any UIElement children and instead draw all its contents directly to the DrawingContext of the VirtualizingCellsControl when the System.Windows.UIElement.OnRender(System.Windows.Media.DrawingContext) method is executed. For a cell renderer it is also possible to do both: Arrange UIElements on the controls area and draw additional contents in its render area. There are also various optimization techniques that can be implemented with the renderer and are discussed in the ICellRenderer overview.
The virtualization of UIElement children of cell renderers is implemented in the arrange cells code. At the time a cell is placed the cell renderer is called to create and intialize the UIElement children. When a cell is scrolled out of view the cell renderer is called to unload the UIElement children. A cell renderer can decide whether to unload a UIElement, keep it alive or move it to a recycle bin and reuse it later. The main logic of this code is implemented by the TreeVirtualizingCellRendererBase<T> class which contains more detailed discussion about this feature.
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Controls.VirtualTreeView
Assembly: Syncfusion.GridCommon.WPF.dll
Syntax
public class VirtualTreeView : VirtualizingCellsControl, IScrollBarProvider, IScrollInfo, IDisposable
Constructors
VirtualTreeView()
Initializes a new instance of the VirtualTreeView class.
Declaration
public VirtualTreeView()
Fields
NodeTemplateProperty
Defines the DataTemplate to use with the expandable node renderer.
Declaration
public static readonly DependencyProperty NodeTemplateProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
Properties
Model
Gets or sets the model.
Declaration
public TreeModel Model { get; set; }
Property Value
Type | Description |
---|---|
TreeModel | The model. |
NodeTemplate
Gets or sets the DataTemplate to use with the expandable node renderer.
Declaration
public DataTemplate NodeTemplate { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.DataTemplate | The node template. |
RenderStyles
Returns a container object which manages cell styles (TreeRenderStyleInfo) of rendered cells that have been scrolled into view.
Declaration
public TreeControlRenderStyles RenderStyles { get; }
Property Value
Type |
---|
TreeControlRenderStyles |
Methods
add_NodeCollapsed(TreeNodeEventHandler)
Declaration
public void add_NodeCollapsed(TreeNodeEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
TreeNodeEventHandler | value |
add_NodeExpanded(TreeNodeEventHandler)
Declaration
public void add_NodeExpanded(TreeNodeEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
TreeNodeEventHandler | value |
add_PrepareRenderCell(TreePrepareRenderCellEventHandler)
Declaration
public void add_PrepareRenderCell(TreePrepareRenderCellEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
TreePrepareRenderCellEventHandler | value |
ArrangeCellUIElements(Size)
Arranges the cells row by row. For each cell the virtual OnArrangeCell(ArrangeCellArgs) method is called. OnArrangeCell gets the ICellRenderer for a cell and calls its Arrange(ArrangeCellArgs) method.
The method also implements the virtualization of UIElement children of cell renderers. It create new UIElement objects for cells scrolled into view or unload UIElements for cells scrolled out of view. If a UIElement has focus whenscrolled out of view it will be kept alive and not unloaded.
Declaration
protected override void ArrangeCellUIElements(Size arrangeSize)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Size | arrangeSize |
Overrides
CreateScrollAxis(Orientation, Boolean, IScrollBar, ILineSizeHost)
Creates the row or column scroll axis. The default implementation of this method creates either a PixelScrollAxis or LineScrollAxis object. You can override this method if you want to add support for another custom tailored scroll axis object.
Declaration
protected override ScrollAxisBase CreateScrollAxis(Orientation orientation, bool pixelScroll, IScrollBar scrollBar, ILineSizeHost lineSizes)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Controls.Orientation | orientation | The orientation (Vertical for row scrolling, Horizontal for column scrolling) |
System.Boolean | pixelScroll | if set to |
IScrollBar | scrollBar | The state of the scroll bar. |
ILineSizeHost | lineSizes | An object that provides row or column sizes. |
Returns
Type | Description |
---|---|
ScrollAxisBase | The scroll axis object. |
Overrides
GetCellRenderer(IRenderCellInfo)
Gets the cell renderer from a render cell style.
Declaration
protected override ICellRenderer GetCellRenderer(IRenderCellInfo cellInfo)
Parameters
Type | Name | Description |
---|---|---|
IRenderCellInfo | cellInfo | The render cell style. |
Returns
Type |
---|
ICellRenderer |
Overrides
GetCellRenderer(DependencyObject)
Gets the CellRendererProperty attached dependency property value.
Declaration
public static TreeCellRenderer GetCellRenderer(DependencyObject dpo)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | dpo | The instance to be queried for the effective value of the dependency property. |
Returns
Type | Description |
---|---|
Syncfusion.Windows.Controls.VirtualTreeView.TreeCellRenderer | Returns the effective value for the given instance. |
GetRenderCellInfo(Int32, Int32)
Gets the render cell style for a cell. VirtualizingCellsControl solely relies on the IRenderCellInfo for drawing and renderer information of a cell. Concrete implementations of this interface such as GridRenderStyleInfo or TreeRenderStyleInfo can add support for additional domain specific properties.
Declaration
protected override IRenderCellInfo GetRenderCellInfo(int rowIndex, int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | Index of the row. |
System.Int32 | columnIndex | Index of the column. |
Returns
Type |
---|
IRenderCellInfo |
Overrides
GetRenderStyleInfo(RowColumnIndex)
Gets the render cell style for a cell. VirtualizingCellsControl solely relies on the IRenderCellInfo for drawing and renderer information of a cell. Concrete implementations of this interface such as GridRenderStyleInfo or TreeRenderStyleInfo can add support for additional domain specific properties.
Declaration
public TreeRenderStyleInfo GetRenderStyleInfo(RowColumnIndex cellRowColumnIndex)
Parameters
Type | Name | Description |
---|---|---|
RowColumnIndex | cellRowColumnIndex | Index of the cell row column. |
Returns
Type |
---|
TreeRenderStyleInfo |
GetRenderStyleInfo(RowColumnIndex, Boolean)
Gets the render cell style for a cell. VirtualizingCellsControl solely relies on the IRenderCellInfo for drawing and renderer information of a cell. Concrete implementations of this interface such as GridRenderStyleInfo or TreeRenderStyleInfo can add support for additional domain specific properties.
Declaration
public TreeRenderStyleInfo GetRenderStyleInfo(RowColumnIndex cellRowColumnIndex, bool createDisposableObject)
Parameters
Type | Name | Description |
---|---|---|
RowColumnIndex | cellRowColumnIndex | Index of the cell row column. |
System.Boolean | createDisposableObject | if set to |
Returns
Type |
---|
TreeRenderStyleInfo |
GetRenderStyleInfo(Int32, Int32)
Gets the render cell style for a cell. VirtualizingCellsControl solely relies on the IRenderCellInfo for drawing and renderer information of a cell. Concrete implementations of this interface such as GridRenderStyleInfo or TreeRenderStyleInfo can add support for additional domain specific properties.
Declaration
public TreeRenderStyleInfo GetRenderStyleInfo(int rowIndex, int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | Index of the row. |
System.Int32 | columnIndex | Index of the column. |
Returns
Type |
---|
TreeRenderStyleInfo |
GetRenderStyleInfo(Int32, Int32, Boolean)
Gets the render cell style for a cell. VirtualizingCellsControl solely relies on the IRenderCellInfo for drawing and renderer information of a cell. Concrete implementations of this interface such as GridRenderStyleInfo or TreeRenderStyleInfo can add support for additional domain specific properties.
Declaration
public TreeRenderStyleInfo GetRenderStyleInfo(int rowIndex, int columnIndex, bool createDisposableObject)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | Index of the row. |
System.Int32 | columnIndex | Index of the column. |
System.Boolean | createDisposableObject | if set to |
Returns
Type |
---|
TreeRenderStyleInfo |
GetRenderStyleInfo(DependencyObject)
Gets the RenderCellInfoProperty attached dependency property value.
Declaration
public static TreeRenderStyleInfo GetRenderStyleInfo(DependencyObject dpo)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | dpo | The instance to be queried for the effective value of the dependency property. |
Returns
Type | Description |
---|---|
TreeRenderStyleInfo | Returns the effective value for the given instance. |
OnPrepareRenderCell(TreePrepareRenderCellEventArgs)
Raises the PrepareRenderCell event and optionally initializes the cells CellValue and CellRenderer.
Declaration
protected virtual void OnPrepareRenderCell(TreePrepareRenderCellEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
TreePrepareRenderCellEventArgs | e | The TreePrepareRenderCellEventArgs instance containing the event data. |
OnPreviewMouseMove(MouseEventArgs)
Implements handling for the PreviewMouseMove�event. When
no mouse button is pressed and the mouse is over a cell it calls
Declaration
protected override void OnPreviewMouseMove(MouseEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Input.MouseEventArgs | e | The System.Windows.Input.MouseEventArgs that contains the event data. |
Overrides
RaiseNodeCollapsed(TreeNodeEventArgs)
Raises the NodeCollapsed event.
Declaration
public void RaiseNodeCollapsed(TreeNodeEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
TreeNodeEventArgs | e | The TreeNodeEventArgs instance containing the event data. |
RaiseNodeExpanded(TreeNodeEventArgs)
Raises the NodeExpanded event.
Declaration
public void RaiseNodeExpanded(TreeNodeEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
TreeNodeEventArgs | e | The TreeNodeEventArgs instance containing the event data. |
RefreshDisplay()
Refreshes the display for the tree clearing Cached Cell Styles, Recalculating Scrollbars and Repainting the whole control.
Declaration
public void RefreshDisplay()
remove_NodeCollapsed(TreeNodeEventHandler)
Declaration
public void remove_NodeCollapsed(TreeNodeEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
TreeNodeEventHandler | value |
remove_NodeExpanded(TreeNodeEventHandler)
Declaration
public void remove_NodeExpanded(TreeNodeEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
TreeNodeEventHandler | value |
remove_PrepareRenderCell(TreePrepareRenderCellEventHandler)
Declaration
public void remove_PrepareRenderCell(TreePrepareRenderCellEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
TreePrepareRenderCellEventHandler | value |
SetCellRenderer(DependencyObject, TreeCellRenderer)
Sets the CellRendererProperty attached dependency property value.
Declaration
public static void SetCellRenderer(DependencyObject dpo, TreeCellRenderer value)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | dpo | The instance to be assigned the value of the dependency property. |
Syncfusion.Windows.Controls.VirtualTreeView.TreeCellRenderer | value | The value. |
SetRenderStyleInfo(DependencyObject, TreeRenderStyleInfo)
Sets the RenderCellInfoProperty attached dependency property value.
Declaration
public static void SetRenderStyleInfo(DependencyObject dpo, TreeRenderStyleInfo value)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | dpo | The instance to be assigned the value of the dependency property. |
TreeRenderStyleInfo | value | The value. |
Events
NodeCollapsed
Occurs when a node was collapsed.
Declaration
public event TreeNodeEventHandler NodeCollapsed
Event Type
Type |
---|
TreeNodeEventHandler |
NodeExpanded
Occurs when node was expanded.
Declaration
public event TreeNodeEventHandler NodeExpanded
Event Type
Type |
---|
TreeNodeEventHandler |
PrepareRenderCell
Occurs just before a cell is arranged on the display in the tree control and allows you to change the settings of the TreeRenderStyleInfo. Changes made to the style's properties will only be made for rendering the style and will not be commited back to the tree node.
Declaration
public event TreePrepareRenderCellEventHandler PrepareRenderCell
Event Type
Type |
---|
TreePrepareRenderCellEventHandler |