Export (0) Print
Expand All

TreeView.SelectedItem Property

Gets the selected item in a TreeView.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[BindableAttribute(true)] 
public Object SelectedItem { get; }
/** @property */
public Object get_SelectedItem ()

public function get SelectedItem () : Object

You cannot use this property in XAML.

Property Value

The selected object in the TreeView, or a null reference (Nothing in Visual Basic) if no item is selected. The default value is a null reference (Nothing in Visual Basic).

Identifier field

SelectedItemProperty

Metadata properties set to true

None

The SelectedItem property on the TreeView control is a read-only property and is set to an item when the IsSelected property value of the item TreeView is set to true.

The following example shows how to get the value of the SelectedItem property.

TreeViewItem selectedTVI = (TreeViewItem)myTreeView.SelectedItem;

More Code

How to: Use SelectedValue, SelectedValuePath, and SelectedItem

This example shows how to use the SelectedValue and SelectedValuePath properties to specify a value for the SelectedItem of a TreeView.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft