Ejemplo n.º 1
0
        static void OnTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            QuickAccessMenuItem quickAccessMenuItem = (QuickAccessMenuItem)d;
            IRibbonControl      ribbonControl       = e.NewValue as IRibbonControl;

            if ((quickAccessMenuItem.Header == null) && (ribbonControl != null))
            {
                // Set Default Text Value
                RibbonControl.Bind(ribbonControl, quickAccessMenuItem, "Header", HeaderProperty, BindingMode.OneWay);
            }
            if (ribbonControl != null)
            {
                DependencyObject parent = LogicalTreeHelper.GetParent((DependencyObject)ribbonControl);
                if (parent == null)
                {
                    quickAccessMenuItem.AddLogicalChild(ribbonControl);
                }
            }
            IRibbonControl oldRibbonControl = e.OldValue as IRibbonControl;

            if (oldRibbonControl != null)
            {
                DependencyObject parent = LogicalTreeHelper.GetParent((DependencyObject)oldRibbonControl);
                if (parent == quickAccessMenuItem)
                {
                    quickAccessMenuItem.RemoveLogicalChild(oldRibbonControl);
                }
            }
        }
Ejemplo n.º 2
0
        static void OnTargetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            QuickAccessMenuItem quickAccessMenuItem = (QuickAccessMenuItem)d;
            RibbonControl       ribbonControl       = e.NewValue as RibbonControl;

            if ((String.IsNullOrEmpty(quickAccessMenuItem.Text)) && (ribbonControl != null))
            {
                // Set Default Text Value
                Bind(ribbonControl, quickAccessMenuItem, "Text", TextProperty, BindingMode.OneWay);
            }
            if (ribbonControl != null)
            {
                DependencyObject parent = LogicalTreeHelper.GetParent(ribbonControl);
                if (parent == null)
                {
                    quickAccessMenuItem.AddLogicalChild(ribbonControl);
                }
            }
            RibbonControl oldRibbonControl = e.OldValue as RibbonControl;

            if (oldRibbonControl != null)
            {
                DependencyObject parent = LogicalTreeHelper.GetParent(oldRibbonControl);
                if (parent == quickAccessMenuItem)
                {
                    quickAccessMenuItem.RemoveLogicalChild(oldRibbonControl);
                }
            }
        }