SelectedValuePath Property

Selector.SelectedValuePath Property


Gets or sets the path that is used to get the SelectedValue from the SelectedItem.

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

public string SelectedValuePath { get; set; }

Property Value

Type: System.String

The path used to get the SelectedValue. The default is an empty string.

The SelectedValuePath property specifies the path to the property that is used to determine the value of the SelectedValue property.

Identifier field


Metadata properties set to true


The following example binds a ListBox to a collection of Employee objects. The example sets SelectedValuePath to @EmployeeNumber and SelectedValue to 12345. This selects the Employee that has 12345 as the value of EmployeeNumber. This example also binds a TextBlock to the SelectedValue of the ListBox. When the user changes the selection in the ListBox, the TextBlock is updated to show the employee number of the currently selected employee.

<XmlDataProvider x:Key="Employees" XPath="/Employees/*">
    <Employees xmlns="">
      <Employee Name="Terry Adams" Type="FTE" EmployeeNumber="1" />
      <Employee Name="Claire O&apos;Donnell" Type="FTE" EmployeeNumber="12345" />
      <Employee Name="Palle Peterson" Type="FTE" EmployeeNumber="5678" />
      <Employee Name="Amy E. Alberts" Type="CSG" EmployeeNumber="99222" />
      <Employee Name="Stefan Hesse" Type="Vendor" EmployeeNumber="-" />

<DataTemplate x:Key="EmployeeItemTemplate">
  <TextBlock Text="{Binding XPath=@Name}" />
<ListBox Name="employeeListBox"
         ItemsSource="{Binding Source={StaticResource Employees}}"
         ItemTemplate="{StaticResource EmployeeItemTemplate}"

<TextBlock Text="{Binding ElementName=employeeListBox, 

.NET Framework
Available since 3.0
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Return to top
© 2015 Microsoft