Partage via


Selector.IsSynchronizedWithCurrentItem Propriété

Définition

Obtient ou définit une valeur qui indique si un Selector doit conserver la SelectedItem synchronisée avec l’élément actif dans la propriété Items.

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)

Valeur de propriété

true si le SelectedItem est toujours synchronisé avec l’élément actuel dans le ItemCollection; false si le SelectedItem n’est jamais synchronisé avec l’élément actuel ; null si le SelectedItem est synchronisé avec l’élément actif uniquement si le Selector utilise un CollectionView. La valeur par défaut est null.

Attributs

Exemples

L’exemple suivant lie deux contrôles ListBox au même ItemsSource. Étant donné que IsSynchronizedWithCurrentItem est défini sur true sur chaque ListBox, l’élément sélectionné est toujours le même pour les deux contrôles

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

Remarques

Vous pouvez définir la propriété IsSynchronizedWithCurrentItem sur true pour vous assurer que l’élément sélectionné correspond toujours à la propriété CurrentItem dans le ItemCollection. Par exemple, supposons qu’il existe deux contrôles ListBox avec leur propriété ItemsSource définie sur la même source. Définissez IsSynchronizedWithCurrentItem sur true dans les deux zones de liste pour vous assurer que l’élément sélectionné dans chaque ListBox est le même.

Utilisation des attributs XAML

< objetIsSynchronizedWithCurrentItem= »Boolean« />

-ou-

< objetIsSynchronizedWithCurrentItem= »{}« />

Informations sur les propriétés de dépendance

Champ d’identificateur IsSynchronizedWithCurrentItemProperty
Propriétés de métadonnées définies sur true Aucun

S’applique à