Selector.IsSynchronizedWithCurrentItem 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定值,這個值表示 Selector 是否應維持 SelectedItem 與 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)
屬性值
如果 SelectedItem 一直與 ItemCollection 中的目前項目同步,則為 true
。如果 SelectedItem 永遠不與目前項目同步,則為 false
。如果 SelectedItem 僅在 Selector 使用 CollectionView 時與目前項目同步,則為 null
。 預設值是 null
。
- 屬性
範例
下列範例會將兩個 ListBox 控制項系結至相同的 ItemsSource 。 由於 IsSynchronizedWithCurrentItem 在每 ListBox 一個 上都設定為 true
,因此這兩個控制項的選取專案一律相同
<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"/>
備註
您可以將 屬性設定 IsSynchronizedWithCurrentItem 為 true
,以確保選取的專案一律會對應至 CurrentItem 中的 ItemCollection 屬性。 例如,假設有兩 ListBox 個控制項的 ItemsSource 屬性設定為相同的來源。 在這 IsSynchronizedWithCurrentItem 兩個清單方塊中設定為 true
,以確保每個 ListBox 清單中選取的專案都相同。
XAML Attribute Usage
<物件IsSynchronizedWithCurrentItem
="Boolean"/>
-或-
<物件IsSynchronizedWithCurrentItem
="{}"/>
相依性屬性資訊
識別碼欄位 | IsSynchronizedWithCurrentItemProperty |
中繼資料屬性設定為 true |
無 |
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應