Selector.SelectedValuePath Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the path that is used to get the SelectedValue from the SelectedItem.
public:
property System::String ^ SelectedValuePath { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
[System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)]
public string SelectedValuePath { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)>]
member this.SelectedValuePath : string with get, set
Public Property SelectedValuePath As String
The path used to get the SelectedValue. The default is an empty string.
- Attributes
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/*">
<x:XData>
<Employees xmlns="">
<Employee Name="Terry Adams" Type="FTE" EmployeeNumber="1" />
<Employee Name="Claire O'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="-" />
</Employees>
</x:XData>
</XmlDataProvider>
<DataTemplate x:Key="EmployeeItemTemplate">
<TextBlock Text="{Binding XPath=@Name}" />
</DataTemplate>
<ListBox Name="employeeListBox"
ItemsSource="{Binding Source={StaticResource Employees}}"
ItemTemplate="{StaticResource EmployeeItemTemplate}"
SelectedValue="12345"
SelectedValuePath="@EmployeeNumber"/>
<TextBlock Text="{Binding ElementName=employeeListBox,
Path=SelectedValue}"/>
The SelectedValuePath property specifies the path to the property that is used to determine the value of the SelectedValue property.
Identifier field | SelectedValuePathProperty |
Metadata properties set to true |
None |
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: