Skip to content

Commit

Permalink
Fixes #666 by refining size restriction strategy for GalleryGroupCont…
Browse files Browse the repository at this point in the history
…ainer
  • Loading branch information
batzen committed Nov 17, 2018
1 parent 389bdc1 commit 2a4faae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
- [#656](../../issues/656) - Backstage icons not showing
- [#659](../../issues/659) - Fix Dutch localization errors (thanks @carloslubbers)
- [#662](../../issues/662) - Backstage/StartScreen closing if clicking outside of Application
- [#666](../../issues/666) - InRibbonGallery DropDown not layouting correctly

- ### Enhancements
- [#516](../../issues/516) - Add options to hide the row containing RibbonTabItems
Expand Down
1 change: 1 addition & 0 deletions Fluent.Ribbon.Showcase/TestContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2007,6 +2007,7 @@ Pellentesque nec dolor sed lacus tristique rutrum sed vitae urna. Sed eu pharetr
<!--InRibbonGallery-->
<Fluent:InRibbonGallery MinItemsInRow="3"
MaxItemsInRow="5"
MaxItemsInDropDownRow="2"
Icon="Images\Gray.png"
Header="InRibbonGallery"
ItemWidth="40"
Expand Down
17 changes: 12 additions & 5 deletions Fluent.Ribbon/Controls/GalleryGroupContainer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ReSharper disable once CheckNamespace
// ReSharper disable once CheckNamespace
namespace Fluent
{
using System;
Expand Down Expand Up @@ -229,10 +229,17 @@ private void UpdateMinAndMaxWidth()

this.minMaxWidthNeedsToBeUpdated = false;

var isInsideInRibbonGallery = UIHelper.GetParent<InRibbonGallery>(this) != null;
var targetForSizeConstraints = isInsideInRibbonGallery ? (FrameworkElement)this : this.RealItemsPanel;

var nonTargetForSizeConstraints = isInsideInRibbonGallery ? (FrameworkElement)this.RealItemsPanel : this;
// Issue references:
// - #452 + commit https://github.com/fluentribbon/Fluent.Ribbon/commit/8b458b1cfc5e440f54778c808142fffa67a23978
// - #666
// We need to check if we are inside a closed InRibbonGallery.
// - If we are inside an closed InRibbonGallery we need to restrict the size of "this"
// - If we are inside an opened InRibbonGallery or not inside an InRibbonGallery we need to restrict the size of "RealItemsPanel"
var inRibbonGallery = UIHelper.GetParent<InRibbonGallery>(this);
var isInsideClosedInRibbonGallery = inRibbonGallery != null && inRibbonGallery.IsDropDownOpen == false;
var targetForSizeConstraints = isInsideClosedInRibbonGallery ? (FrameworkElement)this : this.RealItemsPanel;

var nonTargetForSizeConstraints = isInsideClosedInRibbonGallery ? (FrameworkElement)this.RealItemsPanel : this;

nonTargetForSizeConstraints.MinWidth = 0;
nonTargetForSizeConstraints.MaxWidth = double.PositiveInfinity;
Expand Down

0 comments on commit 2a4faae

Please sign in to comment.