TreeView.SelectedValuePath TreeView.SelectedValuePath TreeView.SelectedValuePath TreeView.SelectedValuePath Property


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

 property System::String ^ SelectedValuePath { System::String ^ get(); void set(System::String ^ value); };
public string SelectedValuePath { get; set; }
member this.SelectedValuePath : string with get, set
Public Property SelectedValuePath As String

Property Value

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


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.

<TreeView ItemsSource="{Binding Source={StaticResource myEmployeeData}, 
    ItemTemplate={StaticResource SampleTemplate},

<TextBlock Margin="10">SelectedValuePath: </TextBlock>
<TextBlock Margin="10,0,0,0" 
           Text="{Binding ElementName=myTreeView, 

<TextBlock Margin="10">SelectedValue: </TextBlock>
<TextBlock Margin="10,0,0,0" 
           Text="{Binding ElementName=myTreeView, 


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 EmployeeNumber. 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.

Dependency Property Information

Identifier field SelectedValuePathProperty
Metadata properties set to true None

Applies to

See also