Microsoft.Windows.Controls.Ribbon.RibbonGallery.UpdateIsSynchronizedWithCurrentItemInternal C# (CSharp) Méthode

UpdateIsSynchronizedWithCurrentItemInternal() private méthode

Update the private flag IsSynchronizedWithCurrentItemInternal so that it honor the public property when set and chooses the automatic behavior which is synchornize currency only when bound to an explicit CollectionViewSource.
private UpdateIsSynchronizedWithCurrentItemInternal ( ) : void
Résultat void
        private void UpdateIsSynchronizedWithCurrentItemInternal()
        {
            bool oldValue = IsSynchronizedWithCurrentItemInternal;
            if (oldValue)
            {
                // Stop listening for currency changes
                RemoveCurrentItemChangedListener();
            }

            bool? isSynchronizedWithCurrentItem = IsSynchronizedWithCurrentItem;
            if (isSynchronizedWithCurrentItem.HasValue)
            {
                IsSynchronizedWithCurrentItemInternal = isSynchronizedWithCurrentItem.Value;
            }
            else
            {
                IsSynchronizedWithCurrentItemInternal = IsInitialized && (RibbonGallery.GetSourceCollectionView(this) != null);
            }

            bool newValue = IsSynchronizedWithCurrentItemInternal;
            if (newValue)
            {
                // Listen for currency changes
                AddCurrentItemChangedListener();

                // Synchronize
                SynchronizeWithCurrentItem();
            }

            if (oldValue != newValue)
            {
                // Notify categories
                for (int i = 0; i < Items.Count; i++ )
                {
                    RibbonGalleryCategory category = ItemContainerGenerator.ContainerFromIndex(i) as RibbonGalleryCategory;
                    if (category != null)
                    {
                        if (newValue)
                        {
                            category.AddCurrentItemChangedListener();
                        }
                        else
                        {
                            category.RemoveCurrentItemChangedListener();
                        }
                    }
                }
            }
        }
RibbonGallery