Skip to content

Commit

Permalink
Merge pull request #1048 from MuhammadSulaiman001/control-dropdown-po…
Browse files Browse the repository at this point in the history
…pup-dismissing

DismissOnClickOutside property added to DropDownButton
  • Loading branch information
batzen authored Aug 25, 2022
2 parents 39f1f4c + 2815fe6 commit e90986e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Fluent.Ribbon/Controls/DropDownButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ public string? KeyTip
/// <inheritdoc />
public bool IsContextMenuOpened { get; set; }

#region DismissOnClickOutside

/// <summary>
/// If false: popup will not be dismissed if a mouse click occurred outside the DropDownButon's borders. <para></para>
/// <see cref="IsDropDownOpen"/> and <see cref="ClosePopupOnMouseDown"/> will not be affected by this value.<para/>
/// Default value is True.
/// </summary>
public bool DismissOnClickOutside
{
get => (bool)this.GetValue(DismissOnClickOutsideProperty);
set => this.SetValue(DismissOnClickOutsideProperty, BooleanBoxes.Box(value));
}

/// <summary>Identifies the <see cref="DismissOnClickOutside"/> dependency property.</summary>
public static readonly DependencyProperty DismissOnClickOutsideProperty =
DependencyProperty.Register(nameof(DismissOnClickOutside), typeof(bool), typeof(DropDownButton), new PropertyMetadata(BooleanBoxes.TrueBox));

#endregion

#region Header

/// <inheritdoc />
Expand Down
3 changes: 2 additions & 1 deletion Fluent.Ribbon/Services/PopupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ private static void DismisPopupForAlways(IDropDownControl control, DismissPopupE

private static void DismisPopupForMouseNotOver(IDropDownControl control, DismissPopupEventArgs e)
{
if (control.IsDropDownOpen == false)
if (control.IsDropDownOpen == false ||
control is DropDownButton { DismissOnClickOutside: false })
{
return;
}
Expand Down

0 comments on commit e90986e

Please sign in to comment.