Bagikan melalui


Selector.IsSynchronizedWithCurrentItem Properti

Definisi

Mendapatkan atau menetapkan nilai yang menunjukkan apakah harus Selector tetap SelectedItem disinkronkan dengan item saat ini di Items properti .

public:
 property Nullable<bool> IsSynchronizedWithCurrentItem { Nullable<bool> get(); void set(Nullable<bool> value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.TypeConverter("System.Windows.NullableBoolConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
[System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)]
public bool? IsSynchronizedWithCurrentItem { get; set; }
[System.ComponentModel.Bindable(true)]
[System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)]
[System.ComponentModel.TypeConverter("System.Windows.NullableBoolConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public bool? IsSynchronizedWithCurrentItem { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.ComponentModel.TypeConverter("System.Windows.NullableBoolConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
[<System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)>]
member this.IsSynchronizedWithCurrentItem : Nullable<bool> with get, set
[<System.ComponentModel.Bindable(true)>]
[<System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)>]
[<System.ComponentModel.TypeConverter("System.Windows.NullableBoolConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
member this.IsSynchronizedWithCurrentItem : Nullable<bool> with get, set
Public Property IsSynchronizedWithCurrentItem As Nullable(Of Boolean)

Nilai Properti

true SelectedItem jika selalu disinkronkan dengan item saat ini di ; false jika SelectedItem tidak pernah disinkronkan ItemCollectiondengan item saat ini; null jika SelectedItem disinkronkan CollectionViewdengan item saat ini hanya jika Selector menggunakan . Nilai defaultnya adalah null.

Atribut

Contoh

Contoh berikut mengikat dua ListBox kontrol ke ItemsSource. Karena IsSynchronizedWithCurrentItem diatur ke true pada setiap ListBox, item yang dipilih selalu sama untuk kedua kontrol

<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="employeeListBox1"
         ItemsSource="{Binding Source={StaticResource Employees}}"
         ItemTemplate="{StaticResource EmployeeItemTemplate}"
         IsSynchronizedWithCurrentItem="True"/>

<ListBox Name="employeeListBox2"
         ItemsSource="{Binding Source={StaticResource Employees}}"
         ItemTemplate="{StaticResource EmployeeItemTemplate}"
         IsSynchronizedWithCurrentItem="True"/>

Keterangan

Anda dapat mengatur IsSynchronizedWithCurrentItem properti ke untuk true memastikan bahwa item yang dipilih selalu sesuai dengan CurrentItem properti di ItemCollection. Misalnya, ada dua ListBox kontrol dengan propertinya ItemsSource yang diatur ke sumber yang sama. Atur IsSynchronizedWithCurrentItem ke true pada kedua kotak daftar untuk memastikan bahwa item yang dipilih di masing-masing ListBox sama.

Penggunaan Atribut XAML

< ObjekIsSynchronizedWithCurrentItem=""Boolean/>

-atau-

< ObjekIsSynchronizedWithCurrentItem=""{}/>

Informasi Properti Dependensi

Item Nilai
Bidang pengidentifikasi IsSynchronizedWithCurrentItemProperty
Properti metadata diatur ke true Tidak

Berlaku untuk