Selector.SelectedValuePath Propiedad
Definición
Obtiene o establece la ruta de acceso que se utiliza para obtener la propiedad SelectedValue de la propiedad SelectedItem.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; }
member this.SelectedValuePath : string with get, set
Public Property SelectedValuePath As String
Valor de propiedad
La ruta de acceso utilizada para obtener la propiedad SelectedValue.The path used to get the SelectedValue. El valor predeterminado es una cadena vacía.The default is an empty string.
- Atributos
Ejemplos
En el ejemplo siguiente se enlaza un ListBox a una colección de objetos Employee
.The following example binds a ListBox to a collection of Employee
objects. En el ejemplo se establece SelectedValuePath en @EmployeeNumber
y SelectedValue en 12345
.The example sets SelectedValuePath to @EmployeeNumber
and SelectedValue to 12345
. Esto selecciona el Employee
que tiene 12345
como valor de EmployeeNumber
.This selects the Employee
that has 12345
as the value of EmployeeNumber
. En este ejemplo también se enlaza un TextBlock al SelectedValue del ListBox.This example also binds a TextBlock to the SelectedValue of the ListBox. Cuando el usuario cambia la selección en el ListBox, el TextBlock se actualiza para mostrar el número de empleado del empleado seleccionado actualmente.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}"/>
Comentarios
La propiedad SelectedValuePath especifica la ruta de acceso a la propiedad que se utiliza para determinar el valor de la propiedad SelectedValue.The SelectedValuePath property specifies the path to the property that is used to determine the value of the SelectedValue property.
Información sobre propiedades de dependenciaDependency Property Information
Campo de identificadorIdentifier field | SelectedValuePathProperty |
Propiedades de metadatos establecidas en true Metadata properties set to true |
NoneNone |