Selector.IsSynchronizedWithCurrentItem Propiedad

Definición

Obtiene o establece un valor que indica si Selector debe mantener la propiedad SelectedItem sincronizada con el elemento actual en la propiedad 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)

Valor de propiedad

Nullable<Boolean>

Es true si la propiedad SelectedItem siempre está sincronizada con el elemento actual de ItemCollection; es false si la propiedad SelectedItem nunca está sincronizada con el elemento actual; es null si la propiedad SelectedItem está sincronizada con el elemento actual únicamente si el objeto Selector usa CollectionView. El valor predeterminado es null.

Atributos

Ejemplos

En el ejemplo siguiente se enlazan dos ListBox controles a la misma ItemsSource. Dado que IsSynchronizedWithCurrentItem se establece true en en cada ListBox, el elemento seleccionado siempre es el mismo para ambos controles.

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

Comentarios

Puede establecer la IsSynchronizedWithCurrentItem propiedad en true para asegurarse de que el elemento seleccionado siempre corresponde a la CurrentItem propiedad de ItemCollection. Por ejemplo, supongamos que hay dos ListBox controles con su ItemsSource propiedad establecida en el mismo origen. Establézcalo IsSynchronizedWithCurrentItem true en en ambos cuadros de lista para asegurarse de que el elemento seleccionado de cada uno ListBox sea el mismo.

Uso de atributos XAML

<Objeto IsSynchronizedWithCurrentItem =""Boolean/>

o bien

<Objeto IsSynchronizedWithCurrentItem =""{}/>

Información sobre propiedades de dependencia

Campo identificador IsSynchronizedWithCurrentItemProperty
Propiedades de metadatos establecidas en true Ninguno

Se aplica a