Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara authored Dec 10, 2023
1 parent de437bd commit 74b228e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
19 changes: 14 additions & 5 deletions ModernWpf.Controls/CommandBarFlyout/CommandBarFlyout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,6 @@ protected override Control CreatePresenter()
{
var commandBar = new CommandBarFlyoutCommandBar();

commandBar.Opened += delegate
{
SetCurrentValue(ShowModeProperty, FlyoutShowMode.Standard);
};

SharedHelpers.CopyList(PrimaryCommands, commandBar.PrimaryCommands);
SharedHelpers.CopyList(SecondaryCommands, commandBar.SecondaryCommands);

Expand All @@ -235,6 +230,13 @@ protected override Control CreatePresenter()
IsDefaultShadowEnabled = false
};

m_presenter = presenter;

commandBar.Opened += delegate
{
SetCurrentValue(ShowModeProperty, FlyoutShowMode.Standard);
};

commandBar.SetOwningFlyout(this);

m_commandBar = commandBar;
Expand Down Expand Up @@ -270,6 +272,11 @@ private void SetSecondaryCommandsToCloseWhenExecuted()
}
}

internal FlyoutPresenter GetPresenter()
{
return m_presenter;
}

private static void RevokeAndRemove(IDictionary<ICommandBarElement, RoutedEventHandlerRevoker> map, ICommandBarElement element)
{
if (map.TryGetValue(element, out var revoker))
Expand Down Expand Up @@ -297,6 +304,8 @@ private static void RevokeAndClear(IDictionary<ICommandBarElement, RoutedEventHa
Dictionary<ICommandBarElement, RoutedEventHandlerRevoker> m_secondaryToggleButtonUncheckedRevokerByElementMap =
new Dictionary<ICommandBarElement, RoutedEventHandlerRevoker>();

FlyoutPresenter m_presenter;

bool m_isClosingAfterCloseAnimation;
}
}
26 changes: 26 additions & 0 deletions ModernWpf.Controls/CommandBarFlyout/CommandBarFlyoutToolBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows.Threading;
Expand Down Expand Up @@ -179,6 +180,13 @@ public override void OnApplyTemplate()
}
}

// Keep the owning FlyoutPresenter's corner radius in sync with the
// primary commands's corner radius.
if (SharedHelpers.IsRS5OrHigher())
{
BindOwningFlyoutPresenterToCornerRadius();
}

if (OverflowPopup is PopupEx popupEx)
{
popupEx.SuppressFadeAnimation = true;
Expand Down Expand Up @@ -1028,6 +1036,24 @@ internal void ClearShadow()
{
}

void BindOwningFlyoutPresenterToCornerRadius()
{
if (TryGetOwningFlyout(out var actualFlyout))
{
if (GetTemplateChild("LayoutRoot") is Border root)
{
Binding binding = new();
binding.Source = root;
binding.Path = new PropertyPath("CornerRadius");
binding.Mode = BindingMode.OneWay;
if (actualFlyout.GetPresenter() is { } presenter)
{
presenter.SetBinding(ControlHelper.CornerRadiusProperty, binding);
}
}
}
}

private void SecondaryItemsRootSizeChanged(object sender, SizeChangedEventArgs e)
{
//m_secondaryItemsRootSized = true;
Expand Down

0 comments on commit 74b228e

Please sign in to comment.