Bagikan melalui


Selector.SelectedValuePath Properti

Definisi

Mendapatkan atau mengatur jalur yang digunakan untuk mendapatkan SelectedValue dari 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

Nilai Properti

Jalur yang digunakan untuk mendapatkan SelectedValue. Defaultnya adalah string kosong.

Atribut

Contoh

Contoh berikut mengikat ke ListBox kumpulan Employee objek. Contoh diatur SelectedValuePath ke @EmployeeNumber dan SelectedValue ke 12345. Ini memilih Employee yang memiliki 12345 sebagai nilai .EmployeeNumber Contoh ini juga mengikat TextBlock ke SelectedValue dari ListBox. Saat pengguna mengubah pilihan di ListBox, TextBlock diperbarui untuk memperlihatkan nomor karyawan karyawan yang saat ini dipilih.

<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}"/>

Keterangan

Properti SelectedValuePath menentukan jalur ke properti yang digunakan untuk menentukan nilai properti SelectedValue.

Informasi Properti Dependensi

Item Nilai
Bidang pengidentifikasi SelectedValuePathProperty
Properti metadata diatur ke true Tidak

Berlaku untuk

Lihat juga