SelectedValuePath Property

TreeView.SelectedValuePath Property


Gets or sets the path that is used to get the SelectedValue of the SelectedItem in a TreeView.

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

public string SelectedValuePath { get; set; }

Property Value

Type: System.String

A string that contains the path that is used to get the SelectedValue. The default value is String.Empty.

The SelectedValuePath property specifies the path to the property that is used to determine the value of the SelectedValue property. For example, assume that a TreeView is bound to a collection of objects of type Employee, which has two properties called EmployeeName and EnployeeNumber. You can use a HierarchicalDataTemplate to display the value of EmployeeName in the TreeView and set SelectedValuePath to "EmployeeNumber" to have SelectedValue return the value of EmployeeNumber.

Identifier field


Metadata properties set to true


Legacy Code Example

The following example shows a TreeView that uses a HierarchicalDataTemplate to display the EmployeeName and EmployeeWorkDay properties of an Employee and sets the SelectedValue property to the EmployeeNumber. When you select an EmployeeName in the TreeView, the SelectedValue is set to the EmployeeNumber.

Code snippet is not found. Confirm that the code snippet name 'TreeViewSelectedValue' is correct.

.NET Framework
Available since 3.0
Available since 3.0
Return to top
© 2015 Microsoft