diff --git a/Changelog.md b/Changelog.md
index 1bd58071e..3dc38c845 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -160,6 +160,7 @@
During this fix `RibbonTabControl.GetFirstVisibleItem` was renamed to `RibbonTabControl.GetFirstVisibleAndEnabledItem`.
- [#473](../../issues/473) - RibbonWindow does not resize when Children resize and SizeToContent is used
- [#481](../../issues/481) - ToggleButton behaviour is wrong when GroupName is set
+ - [#485](../../issues/485) - InRibbonGallery broken when ItemsSource is empty
- ### Enhancements
- `LayoutTransform` and `RenderTransform` can now be used directly on `RibbonWindow` as this now gets forwarded to the first template child of the window. Have a look at `TestWindow` in the showcase application for an example on how to use it. This was added as the fix for [#430](../../issues/430).
diff --git a/Fluent.Ribbon.Tests/Controls/InRibbonGalleryTests.cs b/Fluent.Ribbon.Tests/Controls/InRibbonGalleryTests.cs
new file mode 100644
index 000000000..a8ad9f954
--- /dev/null
+++ b/Fluent.Ribbon.Tests/Controls/InRibbonGalleryTests.cs
@@ -0,0 +1,24 @@
+namespace Fluent.Tests.Controls
+{
+ using Fluent.Tests.TestClasses;
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class InRibbonGalleryTests
+ {
+ [Test]
+ public void Opening_DropDown_Should_Not_Throw_When_GalleryPanel_Has_No_Width()
+ {
+ var control = new InRibbonGallery
+ {
+ Width = 10,
+ Height = 30
+ };
+
+ using (new TestRibbonWindow(control))
+ {
+ Assert.That(() => control.IsDropDownOpen = true, Throws.Nothing);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.0.csproj b/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.0.csproj
index ec0168317..d3a1b426b 100644
--- a/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.0.csproj
+++ b/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.0.csproj
@@ -61,6 +61,7 @@
+
diff --git a/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.5.csproj b/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.5.csproj
index 78ca271d4..341d07470 100644
--- a/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.5.csproj
+++ b/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.5.csproj
@@ -61,6 +61,7 @@
+
diff --git a/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.6.2.csproj b/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.6.2.csproj
index f53ed9fb7..4909b837e 100644
--- a/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.6.2.csproj
+++ b/Fluent.Ribbon.Tests/Fluent.Ribbon.Tests.NET 4.6.2.csproj
@@ -61,6 +61,7 @@
+
diff --git a/Fluent.Ribbon/Controls/InRibbonGallery.cs b/Fluent.Ribbon/Controls/InRibbonGallery.cs
index fa84ba615..40b2fe5c7 100644
--- a/Fluent.Ribbon/Controls/InRibbonGallery.cs
+++ b/Fluent.Ribbon/Controls/InRibbonGallery.cs
@@ -728,14 +728,22 @@ public bool IsSnapped
if (value
&& (int)this.ActualWidth > 0
- && (int)this.ActualHeight > 0)
+ && (int)this.ActualHeight > 0
+ && (int)this.galleryPanel.ActualWidth > 0
+ && (int)this.galleryPanel.ActualHeight > 0)
{
// Render the freezed image
RenderOptions.SetBitmapScalingMode(this.snappedImage, BitmapScalingMode.NearestNeighbor);
- var renderTargetBitmap = new RenderTargetBitmap((int)this.galleryPanel.ActualWidth,
- (int)this.galleryPanel.ActualHeight, 96, 96,
- PixelFormats.Pbgra32);
+
+ var renderTargetBitmap = new RenderTargetBitmap(
+ (int)this.galleryPanel.ActualWidth,
+ (int)this.galleryPanel.ActualHeight,
+ 96,
+ 96,
+ PixelFormats.Pbgra32);
+
renderTargetBitmap.Render(this.galleryPanel);
+
this.snappedImage.Source = renderTargetBitmap;
this.snappedImage.FlowDirection = this.FlowDirection;
this.snappedImage.Width = this.galleryPanel.ActualWidth;