Selector.IsSynchronizedWithCurrentItem Propriété

Définition

Obtient ou définit une valeur qui indique si un Selector doit maintenir la synchronisation du SelectedItem avec l'élément actuel de 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 du ItemCollection ; false si le SelectedItem n'est jamais synchronisé avec l'élément actuel ; null si le SelectedItem n'est synchronisé avec l'élément actuel que si le Selector utilise un CollectionView. La valeur par défaut est null.

Attributs

Exemples

L’exemple suivant lie deux ListBox contrôles au même ItemsSource. Étant donné que IsSynchronizedWithCurrentItem est défini 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é sur trueIsSynchronizedWithCurrentItem pour vous assurer que l’élément sélectionné correspond toujours à la CurrentItem propriété dans le ItemCollection. Par exemple, supposons qu’il existe deux ListBox contrôles dont la ItemsSource propriété est définie sur la même source. true Définissez IsSynchronizedWithCurrentItem sur sur les deux zones de liste pour vous assurer que l’élément sélectionné dans chacune d’elles ListBox est identique.

Utilisation d'attributs XAML

<ObjetIsSynchronizedWithCurrentItem ="Boolean"/>

-ou-

<ObjetIsSynchronizedWithCurrentItem ="{}"/>

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

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

S’applique à