Selector.IsSynchronizedWithCurrentItem Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit une valeur qui indique si un Selector doit conserver la SelectedItem synchronisation avec l’élément actif dans la Items propriété.
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 la SelectedItem valeur est toujours synchronisée avec l’élément actif dans le ItemCollection; false si elle SelectedItem n’est jamais synchronisée avec l’élément actif ; null si elle SelectedItem est synchronisée avec l’élément actif uniquement si elle 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é qu’il IsSynchronizedWithCurrentItem est défini true sur chacun d’eux 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 IsSynchronizedWithCurrentItem propriété pour true 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. Définissez IsSynchronizedWithCurrentItem la valeur true sur les deux zones de liste pour vous assurer que l’élément sélectionné dans chacun d’eux ListBox est le même.
Utilisation des attributs XAML
<
ObjetIsSynchronizedWithCurrentItem="""Boolean/>
-ou-
<
ObjetIsSynchronizedWithCurrentItem="""{}/>
Informations sur les propriétés de dépendance
| Élément | Valeur |
|---|---|
| Champ d’identificateur | IsSynchronizedWithCurrentItemProperty |
Propriétés de métadonnées définies sur true |
Aucun |