private void SynchronizeWithCurrentItem()
{
if (IsSynchronizedWithCurrentItemInternal)
{
object selectedItem = SelectedItem;
if (selectedItem != null)
{
// If there is a SelectedItem synchronize
// CurrentItem to match it
RibbonGalleryCategory category;
RibbonGalleryItem galleryItem;
bool ignoreItemContainerGeneratorStatus = false;
if (ContainsItem(selectedItem, ignoreItemContainerGeneratorStatus, out category, out galleryItem))
{
SynchronizeWithCurrentItem(category, selectedItem);
}
}
else
{
// Since there isn't already a SelectedItem
// synchronize it to match CurrentItem
//
// It is possible that the RibbonGalleryCategory containers
// haven't been generated at the time that we attempt this
// synchronization. In such a case we retry when the
// containers have been generated.
if (ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
{
OnCurrentItemChanged();
}
OnSourceCollectionViewCurrentItemChanged();
}
}
}