Skip to content

Commit

Permalink
Fixes #758 by falling back to ItemsControlFromItemContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Jan 22, 2020
1 parent 76db4f8 commit 160b22f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog for Fluent.Ribbon

## 7.1.0
## 7.1.0 (preview)
- ### Bug fixes
- [#745](../../issues/745) - SplitButton.IsEnabled based on Command.CanExecute?
- [#758](../../issues/758) - Auto menu expanding not working for MenuItems with ItemSource binding
- [#765](../../issues/765) - InRibbonGallery Resizing Issues
- [#766](../../issues/766) - Resizing of InRibbonGallery in a DataTemplate does not work

Expand Down
25 changes: 22 additions & 3 deletions Fluent.Ribbon/Controls/MenuItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,25 @@ protected override bool IsItemItsOwnContainerOverride(object item)

#region Non MenuBase ItemsControl workarounds

/// <summary>
/// Returns logical parent; either Parent or ItemsControlFromItemContainer(this).
/// </summary>
/// <remarks>
/// Copied from <see cref="System.Windows.Controls.MenuItem"/>.
/// </remarks>
public object LogicalParent
{
get
{
if (this.Parent != null)
{
return this.Parent;
}

return ItemsControlFromItemContainer(this);
}
}

/// <inheritdoc />
protected override void OnIsKeyboardFocusedChanged(DependencyPropertyChangedEventArgs e)
{
Expand All @@ -431,7 +450,7 @@ protected override void OnMouseEnter(MouseEventArgs e)
&& this.isContextMenuOpening == false)
{
if (this.HasItems
&& this.Parent is DropDownButton)
&& this.LogicalParent is DropDownButton)
{
this.IsSubmenuOpen = true;
}
Expand All @@ -447,8 +466,8 @@ protected override void OnMouseLeave(MouseEventArgs e)
&& this.isContextMenuOpening == false)
{
if (this.HasItems
&& this.Parent is DropDownButton // prevent too slow close on regular DropDown
&& this.Parent is ApplicationMenu == false) // prevent eager close on ApplicationMenu
&& this.LogicalParent is DropDownButton // prevent too slow close on regular DropDown
&& this.LogicalParent is ApplicationMenu == false) // prevent eager close on ApplicationMenu
{
this.IsSubmenuOpen = false;
}
Expand Down

0 comments on commit 160b22f

Please sign in to comment.