Microsoft.Windows.Controls.Ribbon.RibbonContentPresenter.TransferPseudoInheritedProperties C# (CSharp) Method

TransferPseudoInheritedProperties() private method

private TransferPseudoInheritedProperties ( ) : void
return void
        private void TransferPseudoInheritedProperties()
        {
            if (_templateRoot != null)
            {
                // Ribbon is an inherited property. In non-MVVM scenarios where
                // controls are directly added under RibbonGroup in XAML, RibbonGroup
                // is the logical parent of those controls and they get the value
                // of RibbonParent set from their logical parent. When a RibbonGroup
                // get collapsed and its template changes, due to a bug in framework
                // the inheritance value of those controls is lost during visual tree
                // change and never again gets updated. The workaround is to set the
                // local value on those controls from RibbonContentPresenter which
                // would be their visual parent. This works because Ribbon property is
                // readonly.
                RibbonControlService.SetRibbon(_templateRoot, RibbonControlService.GetRibbon(this));
                RibbonHelper.TransferPseudoInheritedProperties(this, _templateRoot);
            }
        }

Usage Example

        private static void OnIsInControlGroupChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RibbonContentPresenter rcp = (RibbonContentPresenter)d;

            rcp.TransferPseudoInheritedProperties();
        }