Skip to content

Commit

Permalink
Fixes fluentribbon#454 by forcing Measure and Arrange with the curren…
Browse files Browse the repository at this point in the history
…t window size
  • Loading branch information
batzen authored and dady8889 committed Aug 23, 2017
1 parent 8c98bc1 commit 83d889c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
- [#439](../../issues/439) - Context menu and submenu disappears after a right click
- [#446](../../issues/446) - Wrong submenu Position in application menu
- [#450](../../issues/450) - Fix Ribbon.OnTitleBarChanged clearing the new title bar instead of the old one (thanks @Cubey2019)
- [#454](../../issues/454) - RibbonWindow title not shown in correct position when using SizeToContent
- [#457](../../issues/457) - Using the keytip shortcut to open a backstage briefly opens it, then closes it immediately
- [#459](../../issues/459) - Label of the Spinner disappears, if there isn't enough place

Expand Down
18 changes: 17 additions & 1 deletion Fluent.Ribbon/Controls/RibbonWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ static RibbonWindow()
public RibbonWindow()
{
this.SizeChanged += this.OnSizeChanged;
this.Loaded += this.OnLoaded;

// WindowChromeBehavior initialization has to occur in constructor. Otherwise the load event is fired early and performance of the window is degraded.
this.InitializeWindowChromeBehavior();
this.InitializeWindowChromeBehavior();
}

#endregion
Expand Down Expand Up @@ -258,6 +259,21 @@ private void OnSizeChanged(object sender, SizeChangedEventArgs e)
this.MaintainIsCollapsed();
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
if (this.SizeToContent == SizeToContent.Manual)
{
return;
}

this.RunInDispatcherAsync(() =>
{
var availableSize = new Size(this.ActualWidth, this.ActualHeight);
this.Measure(availableSize);
this.Arrange(new Rect(default(Point), availableSize));
}, DispatcherPriority.ApplicationIdle);
}

private void MaintainIsCollapsed()
{
if (this.IsAutomaticCollapseEnabled == false)
Expand Down

0 comments on commit 83d889c

Please sign in to comment.