TreeView.SelectedValuePath Propiedad

Definición

Obtiene o establece la ruta de acceso que se usa para obtener SelectedValue de SelectedItem en TreeView.Gets or sets the path that is used to get the SelectedValue of the SelectedItem in a TreeView.

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

Valor de propiedad

Cadena que contiene la ruta de acceso que se utiliza para obtener SelectedValue.A string that contains the path that is used to get the SelectedValue. El valor predeterminado es String.Empty.The default value is String.Empty.

Atributos

Ejemplos

HierarchicalDataTemplate En el ejemplo siguiente se TreeView muestra un que utiliza para mostrar EmployeeName las EmployeeWorkDay propiedades y de Employee un y establece SelectedValue la propiedad en EmployeeNumber.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. Al EmployeeName seleccionar un TreeViewen, SelectedValueelse establece en. EmployeeNumberWhen you select an EmployeeName in the TreeView, the SelectedValue is set to the EmployeeNumber.

<TreeView ItemsSource="{Binding Source={StaticResource myEmployeeData}, 
    ItemTemplate={StaticResource SampleTemplate},
    XPath=EmployeeInfo}" 
    Name="myTreeView" 
    SelectedValuePath="EmployeeNumber" 
    />

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

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

Comentarios

La SelectedValuePath propiedad especifica la ruta de acceso a la propiedad que se utiliza para determinar el valor SelectedValue de la propiedad.The SelectedValuePath property specifies the path to the property that is used to determine the value of the SelectedValue property. Por ejemplo, supongamos TreeView que se enlaza a una colección de objetos de Employeetipo, que tiene dos propiedades EmployeeName denominadas y EmployeeNumber.For example, assume that a TreeView is bound to a collection of objects of type Employee, which has two properties called EmployeeName and EmployeeNumber. Puede HierarchicalDataTemplate utilizar un para mostrar el valor de EmployeeName en TreeView y establecido SelectedValuePath en "EmployeeNumber" para SelectedValue que devuelva el valor de 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.

Información sobre propiedades de dependenciaDependency Property Information

Campo de identificadorIdentifier field SelectedValuePathProperty
Propiedades de metadatos establecidas entrueMetadata properties set to true NingunaNone

Se aplica a

Consulte también: