RadTreeView
A hierarchical control used to display a tree of items.
Definition
Namespace:Telerik.Windows.Controls
Assembly:Telerik.Windows.Controls.Navigation.dll
Syntax:
[TelerikToolboxCategory("Navigation")]
[Themable]
public class RadTreeView : ItemsControl, IScrollingServiceCore, IScrollingInfo
Inheritance: objectRadTreeView
Derived Classes:
Implements:
Constructors
Initializes a new instance of the RadTreeView class.
public RadTreeView()
Use this constructor to create and initialize a new instance of the RadTreeView control.
Fields
AutoScrollToSelectedItemProperty
DependencyProperty
Identifies the AutoScrollToSelectedItem property.
public static readonly DependencyProperty AutoScrollToSelectedItemProperty
BringIntoViewModeProperty
DependencyProperty
Identifies the BringIntoView property.
public static readonly DependencyProperty BringIntoViewModeProperty
CheckedItemsProperty
DependencyProperty
Identifies the CheckedItemsProperty dependency property.
public static readonly DependencyProperty CheckedItemsProperty
DragEndedEvent
RoutedEvent
Identifies the DragEnded routed event.
[Obsolete("This property will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public static readonly RoutedEvent DragEndedEvent
DragOverTreeEvent
RoutedEvent
Identifies the DragOverTree routed event.
[Obsolete("This property will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public static readonly RoutedEvent DragOverTreeEvent
DragStartedEvent
RoutedEvent
Identifies the DragStarted routed event.
[Obsolete("This property will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public static readonly RoutedEvent DragStartedEvent
DropExpandDelayProperty
DependencyProperty
Identifies the DropExpandDelay property.
public static readonly DependencyProperty DropExpandDelayProperty
ExpanderStyleProperty
DependencyProperty
Identifies the ExpanderStyle dependency property.
public static readonly DependencyProperty ExpanderStyleProperty
ImagesBaseDirProperty
DependencyProperty
Identifies the ImagesBaseDirectory dependency property.
public static readonly DependencyProperty ImagesBaseDirProperty
IsDragDropEnabledProperty
DependencyProperty
Identifies the IsDragDropEnabled dependency property.
public static readonly DependencyProperty IsDragDropEnabledProperty
IsDragPreviewEnabledProperty
DependencyProperty
Identifies the IsDragPreviewEnabled dependency property.
public static readonly DependencyProperty IsDragPreviewEnabledProperty
IsDragTooltipEnabledProperty
DependencyProperty
Identifies the IsDragTooltipEnabled dependency property.
public static readonly DependencyProperty IsDragTooltipEnabledProperty
IsDropPreviewLineEnabledProperty
DependencyProperty
Identifies the IsDropPreviewLineEnabled dependency property.
public static readonly DependencyProperty IsDropPreviewLineEnabledProperty
IsEditableProperty
DependencyProperty
Identifies the IsEditable dependency property.
public static readonly DependencyProperty IsEditableProperty
IsExpandOnDblClickEnabledProperty
DependencyProperty
Identifies the IsExpandOnDoubleClickEnabled dependency property.
public static readonly DependencyProperty IsExpandOnDblClickEnabledProperty
IsExpandOnSingleClickEnabledProperty
DependencyProperty
Identifies the IsExpandOnSingleClickEnabled dependency property.
public static readonly DependencyProperty IsExpandOnSingleClickEnabledProperty
IsLineEnabledProperty
DependencyProperty
Identifies the IsLineEnabled dependency property.
public static readonly DependencyProperty IsLineEnabledProperty
IsLoadOnDemandEnabledProperty
DependencyProperty
Identifies the IsLoadOnDemandEnabled dependency property.
public static readonly DependencyProperty IsLoadOnDemandEnabledProperty
IsOptionElementsEnabledProperty
DependencyProperty
Identifies the IsOptionElementsEnabled dependency property.
public static readonly DependencyProperty IsOptionElementsEnabledProperty
IsRootLinesEnabledProperty
DependencyProperty
Identifies the IsRootLinesEnabled dependency property.
public static readonly DependencyProperty IsRootLinesEnabledProperty
IsSingleExpandPathProperty
DependencyProperty
Identifies the IsSingleExpandPath dependency property.
public static readonly DependencyProperty IsSingleExpandPathProperty
IsTriStateModeProperty
DependencyProperty
Identifies the IsTriStateMode dependency property.
public static readonly DependencyProperty IsTriStateModeProperty
ItemEditTemplateProperty
DependencyProperty
Identifies the ItemEditTemplate dependency property.
public static readonly DependencyProperty ItemEditTemplateProperty
ItemEditTemplateSelectorProperty
DependencyProperty
Identifies the ItemEditTemplateSelector dependency property.
public static readonly DependencyProperty ItemEditTemplateSelectorProperty
ItemsIndentProperty
DependencyProperty
Identifies the ItemsIndent dependency property.
public static readonly DependencyProperty ItemsIndentProperty
PathSeparatorProperty
DependencyProperty
Identifies the PathSeparator dependency property.
public static readonly DependencyProperty PathSeparatorProperty
PerformSelectionOnMouseUpProperty
DependencyProperty
Identifies the PerformSelectionOnMouseUp property.
public static readonly DependencyProperty PerformSelectionOnMouseUpProperty
PreviewDragEndedEvent
RoutedEvent
Identifies the PreviewDragEnded routed event.
[Obsolete("This property will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public static readonly RoutedEvent PreviewDragEndedEvent
PreviewDragStartedEvent
RoutedEvent
Identifies the PreviewDragStarted routed event.
[Obsolete("This property will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public static readonly RoutedEvent PreviewDragStartedEvent
PreviewSelectionChangedEvent
RoutedEvent
Identifies the PreviewSelectionChanged routed event.
public static readonly RoutedEvent PreviewSelectionChangedEvent
SelectedContainerProperty
DependencyProperty
Identifies the SelectedContainer property.
public static readonly DependencyProperty SelectedContainerProperty
SelectedItemProperty
DependencyProperty
Identifies the SelectedItem property.
public static readonly DependencyProperty SelectedItemProperty
SelectedItemsProperty
DependencyProperty
Identifies the SelectedItemsProperty dependency property.
public static readonly DependencyProperty SelectedItemsProperty
SelectedValuePathProperty
DependencyProperty
Identifies the SelectedValuePath dependency property.
public static readonly DependencyProperty SelectedValuePathProperty
SelectedValueProperty
DependencyProperty
Identifies the SelectedValue dependency property.
public static readonly DependencyProperty SelectedValueProperty
SelectionChangedEvent
RoutedEvent
Identifies the SelectionChanged routed event.
public static readonly RoutedEvent SelectionChangedEvent
SelectionModeProperty
DependencyProperty
Identifies the SelectionMode dependency property.
public static readonly DependencyProperty SelectionModeProperty
TextDropAfterProperty
DependencyProperty
Identifies the TextDropAfter dependency property.
public static readonly DependencyProperty TextDropAfterProperty
TextDropBeforeProperty
DependencyProperty
Identifies the TextDropBefore dependency property.
public static readonly DependencyProperty TextDropBeforeProperty
TextDropInProperty
DependencyProperty
Identifies the TextDropIn dependency property.
public static readonly DependencyProperty TextDropInProperty
TextDropRootProperty
DependencyProperty
Identifies the TextDropRoot dependency property.
public static readonly DependencyProperty TextDropRootProperty
TextSearchModeProperty
DependencyProperty
Identifies the TextSearchMode dependency property.
public static readonly DependencyProperty TextSearchModeProperty
Properties
Gets or sets a value indicating whether the selected RadTreeViewItem should be scrolled into the viewport. When using virtualization this property works only for realized RadTreeViewItem(s).
public bool AutoScrollToSelectedItem { get; set; }
Gets or sets whether just the item's header should be brought into view when the respective methods are called of the header and its items.
public BringIntoViewMode BringIntoViewMode { get; set; }
Gets a collection containing the items that are currently checked.
public ICollection<object> CheckedItems { get; }
Gets or sets the time has to pass before an item will be expanded because of something being dragged over it. This is a dependency property.
public TimeSpan DropExpandDelay { get; set; }
ExpanderStyle
Style
Gets or sets the style of RadTreeViewItem expander button.
[Browsable(false)]
public Style ExpanderStyle { get; set; }
The expander button is a ToggleButton. To modify the appearance of the expander first create a Style for a ToggleButton and then set the defined style to this property.
Gets or sets the directory where image files used for the TreeView images.
public string ImagesBaseDir { get; set; }
Gets or sets a value indicating whether drag and drop is enabled.
public bool IsDragDropEnabled { get; set; }
Gets or sets a value indicating whether drag feedback is shown while dragging.
public bool IsDragPreviewEnabled { get; set; }
Gets or sets a value indicating whether drag tooltip is shown while dragging.
public bool IsDragTooltipEnabled { get; set; }
Gets or sets a value indicating whether drag outline is shown while dragging.
public bool IsDropPreviewLineEnabled { get; set; }
Gets or sets a value indicating whether the user can edit the TreeViewItems.
public bool IsEditable { get; set; }
Gets if there is an open editor in the tree view.
[Browsable(false)]
public virtual bool IsEditing { get; }
Gets or sets a value whether the item will toggle its expand state on double click.
public bool IsExpandOnDblClickEnabled { get; set; }
Gets or sets a value indicating whether the item will toggle its expand state on single click.
public bool IsExpandOnSingleClickEnabled { get; set; }
Gets or sets a value indicating whether connecting lines are displayed.
public bool IsLineEnabled { get; set; }
Gets or sets a value indicating whether loading on demand is enabled.
public bool IsLoadOnDemandEnabled { get; set; }
When the value is set to true the expander visual will be visible even if the item do no have children. When the expander visual is clicked, the event is raised and you can populate the node.
Gets or sets a value indicating whether checkboxes/radio buttons are displayed besides the TreeViewItems.
public bool IsOptionElementsEnabled { get; set; }
Gets or sets a value indicating whether lines are displayed next to root item.
public bool IsRootLinesEnabled { get; set; }
Gets a value indicating whether only one branch of the TreeView will be expanded.
public bool IsSingleExpandPath { get; set; }
The property closes all item that are not parents of the last expanded item.
Gets or sets a value indicating whether tri state mode for the checkboxes in the option lists is enabled.
public bool IsTriStateMode { get; set; }
When the value is set to true the checked state of the item depends on the checked state of its child items. When the checked state of the item is changed - the child items state is also changed.
Gets or sets a value indicating whether the TreeView should virtualize its items. Virtualization should be used only when the TreeView is data bound.
public bool IsVirtualizing { get; set; }
This is a CLR wrapper for the TreeViewPanel.IsVirtualizing property. It will only work if the ItemsPanel of the TreeViewItem is a TreeViewPanel.
ItemEditTemplate
DataTemplate
Gets or sets the template that the items will display when edited.
public DataTemplate ItemEditTemplate { get; set; }
The item edit template.
ItemEditTemplateSelector
DataTemplateSelector
Gets or sets the template selector that the items will use to select a template to display when edited.
public DataTemplateSelector ItemEditTemplateSelector { get; set; }
The item edit template selector.
Gets or sets the distance that each tree item level will be indented.
public int ItemsIndent { get; set; }
Gets or sets the delimiter string that the tree item path uses.
public string PathSeparator { get; set; }
The tree item path contains of a set of tree item labels
separated by the PathSeparator delimiter strings.
The default return value is the backslash character ().
Gets or sets a boolean value indicating whether the selection will be performed on mouse up.
public bool PerformSelectionOnMouseUp { get; set; }
ScrollViewer
ScrollViewer
Gets the ScrollViewer control the is inside the RadTreeView.
public ScrollViewer ScrollViewer { get; }
Use the ScrollViewer.HorizontalScrollBarVisibility and ScrollViewer.VerticalScrollBarVisibility attached properties to set the visibility of the ScrollBars.
Gets the TreeViewItem container that is currently selected. This is a dependency property.
public RadTreeViewItem SelectedContainer { get; }
Gets or sets the item that is currently selected. This is a dependency property.
public object SelectedItem { get; set; }
Gets a collection containing the items that are currently selected.
[Browsable(false)]
public ObservableCollection<object> SelectedItems { get; }
Gets or sets the value of the SelectedItem, obtained by using SelectedValuePath.
public object SelectedValue { get; }
Gets or sets the path that is used to extract the SelectedValue from the SelectedItem.
public string SelectedValuePath { get; set; }
SelectionMode
SelectionMode
Gets or sets the selection mode.
public SelectionMode SelectionMode { get; set; }
Gets or sets the text "Drop after" text of the drag preview.
public string TextDropAfter { get; set; }
The text drop after.
Gets or sets the text "Drop before" text of the drag preview.
public string TextDropBefore { get; set; }
The text drop before.
Gets or sets the text for "Drop in" text of the drag preview.
public string TextDropIn { get; set; }
The text drop in.
Gets or sets the text that appears when an item is dropped in an empty TreeView.
public string TextDropRoot { get; set; }
The text drop in.
Gets or sets the text search mode. Specifies how TextSearch will match items. This is a dependency property.
public TextSearchMode TextSearchMode { get; set; }
The text search mode.
Methods
Creates a new item and adds a item by path. The label of the new item will be the text after the last separator.
Creates a new item and adds a item by path. Can be used if the TreeView is not data bound.
public RadTreeViewItem AddItemByPath(string path)
Where the item should be added.
Returns:The new item if the operation is successful.
Brings the item with the given index into view. The method will not work before the item containers have been generated.
public void BringIndexIntoView(int index, Point offset)
The index of the item to be brought into view.
offsetPointThe offset to tree view top left corner where the item should be scrolled to.
Brings the item with the given index into view. The method will not work before the item containers have been generated.
public void BringIndexIntoView(int index)
The index of the item to be brought into view.
Brings the given item into view. This is not a recursive method, it will only work for immediate items. The method will not work before the item containers have been generated.
public void BringItemIntoView(object item, Point offset)
The item to be brought into view.
offsetPointThe offset to tree view top left corner where the item should be scrolled to.
Brings the given item into view. This is not a recursive method, it will only work for immediate items. The method will not work before the item containers have been generated.
public void BringItemIntoView(object item)
The item to be brought into view.
Brings an item into view. Works recursively for nested containers. If the Loaded event has not been fired yet the method will be scheduled for execution after the Loaded event. The method will realize the required containers if they are not yet created.
public void BringPathIntoView(string path, Point offset)
The path of the item to be brought into view.
offsetPointThe offset from the top left corner of the tree where the item will be scrolled to.
Brings an item into view. Works recursively for nested containers. If the Loaded event has not been fired yet the method will be scheduled for execution after the Loaded event. The method will realize the required containers if they are not yet created.
public void BringPathIntoView(string path)
The path of the item to be brought into view.
Updates the visual state of the control.
protected override void ClearContainerForItemOverride(DependencyObject element, object item)
Collapses all items recursively.
public void CollapseAll()
Recursively searches the tree view in the tree to get an item container (RadTreeViewItem) for the particular data item.
Expands all items recursively.
public void ExpandAll()
If a child item is not generated it will be expanded once it is generated.
Expands to an item with a given path.
GetContainerForItemOverride()
DependencyObject
protected override DependencyObject GetContainerForItemOverride()
DependencyObject
Gets a item by specifying a path to it.
public RadTreeViewItem GetItemByPath(string path)
The path to the item.
Returns:The item if found.
Hides the drag cue that appears when a drop between two items is possible.
[Obsolete("This method will be removed. It is not intended for third party usage.", false)]
public void HideBetweenItemsDragCue()
Occurs when the template for the RadTreeView is applied, allowing for custom processing after the template has been applied.
public override void OnApplyTemplate()
OnCreateAutomationPeer()
AutomationPeer
protected override AutomationPeer OnCreateAutomationPeer()
AutomationPeer
Raises the event.
[Obsolete("This method will be removed. Use DragDropManager API to customize drag drop operations.", false)]
protected virtual void OnDragEnded(RadTreeViewDragEndedEventArgs e)
The RadTreeViewDragEndedEventArgs instance containing the event data.
Called when DragEnter Event is Raise.
protected override void OnDragEnter(DragEventArgs e)
Event args.
Called when DragEnter Event is Raise.
protected override void OnDragLeave(DragEventArgs e)
Event args.
Raises the event.
[Obsolete("This method will be removed. Use DragDropManager API to customize drag drop operations.", false)]
protected virtual void OnDragOverTree(DragOverTreeEventArgs e)
The DragOverTreeEventArgs instance containing the event data.
Raises the event.
[Obsolete("This method will be removed. Use DragDropManager API to customize drag drop operations.", false)]
protected virtual void OnDragStarted(RadTreeViewDragEventArgs e)
The RadTreeViewDragEventArgs instance containing the event data.
Called when DragEnter Event is Raise.
protected override void OnDrop(DragEventArgs e)
Event args.
Propagates the changed expander style through tree's children. Called when the ExpanderStyleInherited property changes.
protected virtual void OnExpanderStyleChanged(Style oldStyle, Style newStyle)
The old style.
newStyleStyleThe new style.
Called when the TreeView or one of its items receive focus.
protected virtual void OnGotFocus(object sender, RoutedEventArgs e)
The sender of the event.
eRoutedEventArgsThe event arguments that will be passed to the GotFocus event.
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
Raises the event.
protected virtual void OnItemPrepared(RadTreeViewItemPreparedEventArgs e)
The RadTreeViewDragEndedEventArgs instance containing the event data.
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
Called when the TreeView or one of its items lose focus.
protected virtual void OnLostFocus(object sender, RoutedEventArgs e)
The sender of the event.
eRoutedEventArgsThe event arguments that are passed to the LostFocus event.
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
protected override void OnMouseWheel(MouseWheelEventArgs e)
Raises the event.
[Obsolete("This method will be removed. Use DragDropManager API to customize drag drop operations.", false)]
protected virtual bool OnPreviewDragEnded(RadTreeViewDragEndedEventArgs e)
The RadTreeViewDragEndedEventArgs instance containing the event data.
Returns:Raises the event.
[Obsolete("This method will be removed. Use DragDropManager API to customize drag drop operations.", false)]
protected virtual bool OnPreviewDragStarted(RadTreeViewDragEventArgs e)
The RadTreeViewDragEventArgs instance containing the event data.
Returns:This method is called when the PreviewSelectionChanged is raised.
protected virtual bool OnPreviewSelectionChanged(SelectionChangedEventArgs e)
The event arguments with which the event will be called.
Returns:Returns whether the event was handled.
Not calling the base method in overrides means that the PreviewSelectionChanged event will not be raised.
Raises the event.
protected virtual void OnSelectionChanged(SelectionChangedEventArgs e)
The SelectionChangedEventArgs instance containing the event data.
protected override void OnTextInput(TextCompositionEventArgs e)
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
Resets the theme.
public void ResetTheme()
Adds the item with the given path to the collection of selected items. The path separator is "".
Adds the item with the given path to the collection of selected items. The path separator is "".
public void SelectItemByPath(string path)
A unique path for the item, normally made up of IDs.
Shows the DragCue that appears when a drop between two items is possible.
[Obsolete("This method will be removed. It is not intended for third party usage.", false)]
public void ShowBetweenItemsDragCue(RadTreeViewItem dropDestination)
The relative drop position. In this method only DropPosition.Before and DropPosition.After make sense.
Updates the drop preview line position and visibility while dragging.
public void UpdateDropPreviewLine(RadTreeViewItem dropDestination, DropPosition dropPosition)
Events
Occurs when a child TreeView item has been checked.
public event EventHandler<RadRoutedEventArgs> Checked
Occurs when a child TreeView item has been collapsed.
public event EventHandler<RadRoutedEventArgs> Collapsed
Occurs when the drag has ended.
[Obsolete("This event will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public event RadTreeViewDragEndedEventHandler DragEnded
Occurs when the dragging over the tree view.
[Obsolete("This event will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public event DragOverTreeEventHandler DragOverTree
Occurs when the drag has started.
[Obsolete("This event will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public event RadTreeViewDragEventHandler DragStarted
Raised when item editing has been canceled. This is a wrapper for the EditableHeaderedItemsControl.EditCanceled routed event.
public event RadTreeViewItemEditedEventHandler EditCanceled
Raised when the edit of an item has been committed.
public event RadTreeViewItemEditedEventHandler Edited
Raised when the edit of an item has just started. This is a wrapper for the EditableHeaderedItemsControl.EditStarted routed event.
public event RadTreeViewItemEditedEventHandler EditStarted
Occurs when a child TreeView item has been expanded.
public event EventHandler<RadRoutedEventArgs> Expanded
Occurs when a child TreeView item has been clicked.
public event EventHandler<RadRoutedEventArgs> ItemClick
Occurs when a child TreeView item has been double clicked.
public event EventHandler<RadRoutedEventArgs> ItemDoubleClick
Occurs when a child RadTreeViewItem has been prepared and is ready for use.
public event EventHandler<RadTreeViewItemPreparedEventArgs> ItemPrepared
Use it to perform binding of RadTreeViewItem properties to the data objects.
Occurs when a child TreeView item is loading its child items on demand. See the IsLoadOnDemandEnabled property.
public event EventHandler<RadRoutedEventArgs> LoadOnDemand
Occurs before a child TreeView item is checked.
public event EventHandler<RadRoutedEventArgs> PreviewChecked
Occurs before a child TreeView item is collapsed.
public event EventHandler<RadRoutedEventArgs> PreviewCollapsed
Occurs before the drag has been ended.
[Obsolete("This event will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public event RadTreeViewDragEndedEventHandler PreviewDragEnded
Occurs before the drag is started.
[Obsolete("This event will be removed. Use DragDropManager API to customize drag drop operations.", false)]
public event RadTreeViewDragEventHandler PreviewDragStarted
Raised just before item editing has been canceled. This is a wrapper for the EditableHeaderedItemsControl.PreviewEditCanceled routed event.
public event RadTreeViewItemEditedEventHandler PreviewEditCanceled
Occurs before a TreeView item to accept the new Edited data.
public event RadTreeViewItemEditedEventHandler PreviewEdited
Raised just before editing of an item has started. This is a wrapper for the EditableHeaderedItemsControl.PreviewEditStarted routed event.
public event RadTreeViewItemEditedEventHandler PreviewEditStarted
Occurs before a child TreeView item is expanded.
public event EventHandler<RadRoutedEventArgs> PreviewExpanded
Occurs before a child tree view item is selected.
public event EventHandler<RadRoutedEventArgs> PreviewSelected
PreviewSelectionChanged
SelectionChangedEventHandler
Raised just before the selected items collection has changed.
public event SelectionChangedEventHandler PreviewSelectionChanged
Occurs before a child TreeView item is unchecked.
public event EventHandler<RadRoutedEventArgs> PreviewUnchecked
Occurs before a child tree view item is unselected.
public event EventHandler<RadRoutedEventArgs> PreviewUnselected
Occurs when a child RadTreeView item has been selected.
public event EventHandler<RadRoutedEventArgs> Selected
SelectionChanged
SelectionChangedEventHandler
Occurs after the value of the SelectedItems property of a tree is changed.
public event SelectionChangedEventHandler SelectionChanged
Occurs when a child TreeView item has been unchecked.
public event EventHandler<RadRoutedEventArgs> Unchecked
Occurs when a child tree view item has been unselected.
public event EventHandler<RadRoutedEventArgs> Unselected