.NET Framework Class Library
Selector..::.IsSynchronizedWithCurrentItem Property

Gets or sets a value that indicates whether a Selector should keep the SelectedItem synchronized with the current item in the Items property. This is a dependency property.

Namespace:  System.Windows.Controls.Primitives
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax

Visual Basic (Declaration)
<LocalizabilityAttribute(LocalizationCategory.NeverLocalize)> _
<BindableAttribute(True)> _
<TypeConverterAttribute("System.Windows.NullableBoolConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")> _
Public Property IsSynchronizedWithCurrentItem As Nullable(Of Boolean)
Visual Basic (Usage)
Dim instance As Selector
Dim value As Nullable(Of Boolean)

value = instance.IsSynchronizedWithCurrentItem

instance.IsSynchronizedWithCurrentItem = value
C#
[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)]
[BindableAttribute(true)]
[TypeConverterAttribute("System.Windows.NullableBoolConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public Nullable<bool> IsSynchronizedWithCurrentItem { get; set; }
Visual C++
[LocalizabilityAttribute(LocalizationCategory::NeverLocalize)]
[BindableAttribute(true)]
[TypeConverterAttribute(L"System.Windows.NullableBoolConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public:
property Nullable<bool> IsSynchronizedWithCurrentItem {
    Nullable<bool> get ();
    void set (Nullable<bool> value);
}
JScript
public function get IsSynchronizedWithCurrentItem () : Nullable<boolean>
public function set IsSynchronizedWithCurrentItem (value : Nullable<boolean>)
XAML Attribute Usage
<object IsSynchronizedWithCurrentItem="Boolean"/>- or -<object IsSynchronizedWithCurrentItem="{x:Null}"/>

Property Value

Type: System..::.Nullable<(Of <(Boolean>)>)
true if the SelectedItem is always synchronized with the current item in the ItemCollection; false if the SelectedItem is never synchronized with the current item; nullNothingnullptra null reference (Nothing in Visual Basic) if the SelectedItem is synchronized with the current item only if the Selector uses a CollectionView. The default value is nullNothingnullptra null reference (Nothing in Visual Basic).
Dependency Property Information

Identifier field

IsSynchronizedWithCurrentItemProperty

Metadata properties set to true

None

Remarks

You can set the IsSynchronizedWithCurrentItem property to true to ensure that the item selected always corresponds to the CurrentItem property in the ItemCollection. For example, suppose that there are two ListBox controls with their ItemsSource property set to the same source. Set IsSynchronizedWithCurrentItem to true on both list boxes to ensure that the selected item in each ListBox is the same.

Examples

The following example binds two ListBox controls to the same ItemsSource. Because IsSynchronizedWithCurrentItem is set to true on each ListBox, the selected item is always the same for both controls

XAML
<XmlDataProvider x:Key="Employees" XPath="/Employees/*">
  <x:XData>
    <Employees xmlns="">
      <Employee Name="Terry Adams" Type="FTE" EmployeeNumber="1" />
      <Employee Name="Claire O&apos;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"/>
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Other Resources

Tags :


Community Content

mgolanlan
ahm, if you set it then you can no longer modify SelectedIndex directly

As far as I can see, if you set IsSynchronizedWithCurrentItem="True" then you can no longer set SelectedIndex.

so, if you have XML which fills your CcomboBox as well as track the current item,

ItemsSource="{Binding XPath=combo/item}"
SelectedIndex="{Binding Xpath=combo/selected}"

it will not work if you're Synchronized...

and since its not practical to keep the actual SelectedItem in XML ... don't turn Sync on

Tags : combobox

Page view tracker