RibbonApplicationMenu: getting rid of the AuxiliaryPane

前端 未结 2 475
遇见更好的自我
遇见更好的自我 2021-01-16 02:21

It so happened that the application I\'m working on doesn\'t operate on documents, so there\'s no need in displaying the recently opened documents list in the application me

相关标签:
2条回答
  • 2021-01-16 03:03

    I know this has been a while, but I've got another solution to this. This one does not provide the Popup width property, instead a ShowAuxilaryPanel boolean. It then goes to Bind the width of the Popup, to the width of the menu item area of the menu.

    public class SlimRibbonApplicationMenu : RibbonApplicationMenu
    {
        public bool ShowAuxilaryPanel
        {
            get { return (bool)GetValue(ShowAuxilaryPanelProperty); }
            set { SetValue(ShowAuxilaryPanelProperty, value); }
        }
    
        public static readonly DependencyProperty ShowAuxilaryPanelProperty =
            DependencyProperty.Register("ShowAuxilaryPanel", typeof(bool),
            typeof(SlimRibbonApplicationMenu), new UIPropertyMetadata(true));
    
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.DropDownOpened += SlimRibbonApplicationMenu_DropDownOpened;
        }
    
        void SlimRibbonApplicationMenu_DropDownOpened(object sender, EventArgs e)
        {
            DependencyObject popupObj = base.GetTemplateChild("PART_Popup");
            Popup panel = (Popup)popupObj;
            var exp = panel.GetBindingExpression(Popup.WidthProperty);
    
            if (!this.ShowAuxilaryPanel && exp == null)
            {
                DependencyObject panelArea = base.GetTemplateChild("PART_SubMenuScrollViewer");
    
                var panelBinding = new Binding("ActualWidth")
                {
                    Source = panelArea,
                    Mode = BindingMode.OneWay
                };
                panel.SetBinding(Popup.WidthProperty, panelBinding);
            }
            else if (this.ShowAuxilaryPanel && exp != null)
            {
                BindingOperations.ClearBinding(panel, Popup.WidthProperty);
            }
        }
    }
    
    0 讨论(0)
  • 2021-01-16 03:07

    worked for me

    <telerik:ApplicationMenu RightPaneVisibility="Collapsed" >
    
    0 讨论(0)
提交回复
热议问题