From 83d889c3fce0a0744120be7102ecd41fc45eaf75 Mon Sep 17 00:00:00 2001 From: Bastian Schmidt Date: Fri, 18 Aug 2017 23:08:04 +0200 Subject: [PATCH] Fixes #454 by forcing Measure and Arrange with the current window size --- Changelog.md | 1 + Fluent.Ribbon/Controls/RibbonWindow.cs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 9f9f409ca..c47e3e132 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/Fluent.Ribbon/Controls/RibbonWindow.cs b/Fluent.Ribbon/Controls/RibbonWindow.cs index a415e7d1e..5bd58ade9 100644 --- a/Fluent.Ribbon/Controls/RibbonWindow.cs +++ b/Fluent.Ribbon/Controls/RibbonWindow.cs @@ -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 @@ -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)