@@ -21,7 +21,6 @@ namespace Fluent;
21
21
using Fluent . Helpers ;
22
22
using Fluent . Internal . KnownBoxes ;
23
23
using Fluent . Localization ;
24
- using WindowChrome = ControlzEx . WindowChrome ;
25
24
26
25
// TODO: improve style parts naming & using
27
26
@@ -42,7 +41,7 @@ public class Ribbon : Control, ILogicalChildSupport
42
41
/// <summary>
43
42
/// Gets the current instance for storing the state of this control.
44
43
/// </summary>
45
- public IRibbonStateStorage RibbonStateStorage => this . ribbonStateStorage ?? ( this . ribbonStateStorage = this . CreateRibbonStateStorage ( ) ) ;
44
+ public IRibbonStateStorage RibbonStateStorage => this . ribbonStateStorage ??= this . CreateRibbonStateStorage ( ) ;
46
45
47
46
/// <summary>
48
47
/// Create a new instance for storing the state of this control.
@@ -446,38 +445,43 @@ private static void OnContextMenuOpened(object sender, RoutedEventArgs e)
446
445
//Debug.WriteLine("Menu opened on "+control);
447
446
if ( control is not null )
448
447
{
449
- FirstSeparator . Visibility = Visibility . Visible ;
450
-
451
448
// Check for value because remove is only possible in the context menu of items in QA which represent the value for QA-items
452
- if ( ribbon . QuickAccessElements . ContainsValue ( control ) )
449
+ if ( ribbon . QuickAccessElements . ContainsValue ( control )
450
+ && ( control is not IDropDownControl dropDownControl || dropDownControl . IsDropDownOpen is false ) )
453
451
{
452
+ FirstSeparator . Visibility = Visibility . Visible ;
453
+
454
454
// Control is on quick access
455
455
RemoveFromQuickAccessMenuItem . Visibility = Visibility . Visible ;
456
456
}
457
- else if ( control is System . Windows . Controls . MenuItem )
458
- {
459
- // Control is menu item
460
- AddMenuToQuickAccessMenuItem . Visibility = Visibility . Visible ;
461
- }
462
- else if ( control is Gallery ||
463
- control is InRibbonGallery )
464
- {
465
- // Control is gallery
466
- AddGalleryToQuickAccessMenuItem . Visibility = Visibility . Visible ;
467
- }
468
- else if ( control is RibbonGroupBox )
469
- {
470
- // Control is group box
471
- AddGroupToQuickAccessMenuItem . Visibility = Visibility . Visible ;
472
- }
473
- else if ( control is IQuickAccessItemProvider )
474
- {
475
- // Its other control
476
- AddToQuickAccessMenuItem . Visibility = Visibility . Visible ;
477
- }
478
457
else
479
458
{
480
- FirstSeparator . Visibility = Visibility . Collapsed ;
459
+ FirstSeparator . Visibility = Visibility . Visible ;
460
+
461
+ if ( control is System . Windows . Controls . MenuItem )
462
+ {
463
+ // Control is menu item
464
+ AddMenuToQuickAccessMenuItem . Visibility = Visibility . Visible ;
465
+ }
466
+ else if ( control is Gallery or InRibbonGallery )
467
+ {
468
+ // Control is gallery
469
+ AddGalleryToQuickAccessMenuItem . Visibility = Visibility . Visible ;
470
+ }
471
+ else if ( control is RibbonGroupBox )
472
+ {
473
+ // Control is group box
474
+ AddGroupToQuickAccessMenuItem . Visibility = Visibility . Visible ;
475
+ }
476
+ else if ( control is IQuickAccessItemProvider )
477
+ {
478
+ // Its other control
479
+ AddToQuickAccessMenuItem . Visibility = Visibility . Visible ;
480
+ }
481
+ else
482
+ {
483
+ FirstSeparator . Visibility = Visibility . Collapsed ;
484
+ }
481
485
}
482
486
}
483
487
}
@@ -1507,16 +1511,17 @@ private static void OnAddToQuickAccessCommandCanExecute(object sender, CanExecut
1507
1511
{
1508
1512
if ( sender is Ribbon ribbon
1509
1513
&& ribbon . IsQuickAccessToolBarVisible
1510
- && QuickAccessItemsProvider . IsSupported ( e . Parameter as UIElement )
1511
- && ribbon . IsInQuickAccessToolBar ( e . Parameter as UIElement ) == false )
1514
+ && e . Parameter is UIElement element
1515
+ && QuickAccessItemsProvider . IsSupported ( element )
1516
+ && ribbon . IsInQuickAccessToolBar ( element ) is false )
1512
1517
{
1513
1518
if ( e . Parameter is Gallery gallery )
1514
1519
{
1515
1520
e . CanExecute = ribbon . IsInQuickAccessToolBar ( FindParentRibbonControl ( gallery ) as UIElement ) == false ;
1516
1521
}
1517
1522
else
1518
1523
{
1519
- e . CanExecute = ribbon . IsInQuickAccessToolBar ( e . Parameter as UIElement ) == false ;
1524
+ e . CanExecute = ribbon . IsInQuickAccessToolBar ( element ) == false ;
1520
1525
}
1521
1526
}
1522
1527
else
0 commit comments