TreeView.SelectedValue Property

Gets the value of the component of the SelectedItem at the specified SelectedValuePath.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:

public Object SelectedValue { get; }
/** @property */
public Object get_SelectedValue ()

public function get SelectedValue () : Object

You cannot use this property in XAML.

Property Value

The object that is at the specified SelectedValuePath of the SelectedItem, 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


Metadata properties set to true


The SelectedValue is determined by the value of the SelectedValuePath property. For more information, see How to: Use SelectedValue, SelectedValuePath and SelectedItem.

The SelectedValue property is a read-only property. To change the value of a selected item in a TreeView, use the SelectedItem property to access the TreeViewItem.

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

TreeViewItem selectedTVValue = (TreeViewItem)myTreeView.SelectedValue;

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