fluentribbon / Fluent.Ribbon

WPF Ribbon control like in Office
http://fluentribbon.github.io
MIT License
2.56k stars 517 forks source link

MenuItem CreateQuickAccessItem should create ToggleButton #1041

Closed andersforsgren closed 2 years ago

andersforsgren commented 2 years ago

The Fluent.MenuItem class when there are no child menu items, produces a regular Button as its QuickAccessItem.

This means the MenuItem.IsChecked is not reflected as the toggle state on the QAT button.

current impl in MenuItem.cs

else // no child items 
{
    var button = new Button();
    RibbonControl.BindQuickAccessItem(this, button);
    return button;
}

I suggest this should instead return a ToggleButton. The rationale being that a MenuItem, being checkable, is more similar to a ToggleButton than a Button.

So basically instead, this:

 else // no child items 
 {
     var button = new ToggleButton();
     RibbonControl.Bind(this, button, nameof(this.IsChecked), IsCheckedProperty, BindingMode.TwoWay);
     RibbonControl.BindQuickAccessItem(this, button);
     return button;
 }

If this looks reasonable I’m happy to supply a PR


Environment

batzen commented 2 years ago

Actually both would be wrong alone, as the result should depend on the check ability of the menu item. 😉

andersforsgren commented 2 years ago

Yes I suppose the correct way would be to make it conditional on IsCheckable and make either a Button or a ToggleButton?

I will give it a try