diff --git a/Fluent.Ribbon.Showcase/TestContent.xaml b/Fluent.Ribbon.Showcase/TestContent.xaml index 8e3def347..29b7f64da 100644 --- a/Fluent.Ribbon.Showcase/TestContent.xaml +++ b/Fluent.Ribbon.Showcase/TestContent.xaml @@ -3588,6 +3588,9 @@ </GroupBox> <GroupBox Header="Issue repros"> <WrapPanel> + <WrapPanel.Resources> + <Fluent:ObjectToImageConverter x:Key="StringToImageConvert"/> + </WrapPanel.Resources> <Fluent:Button x:Name="SleepButton" VerticalAlignment="Top" Click="SleepButton_OnClick" @@ -3602,6 +3605,13 @@ Change theme from thread </Fluent:Button> + <Fluent:Button VerticalAlignment="Top" + Tag="/Images/Blue.png" + Icon="{Binding Path=Tag,RelativeSource={RelativeSource Self},Converter={StaticResource StringToImageConvert}}" + Size="Middle"> + ObjectToImageConverter for issue #1152 + </Fluent:Button> + <GroupBox Header="KeyTip issues #254"> <StackPanel Orientation="Vertical"> <formsInterop:WindowsFormsHost> diff --git a/Fluent.Ribbon.Tests/Converters/ObjectToImageConverterTests.cs b/Fluent.Ribbon.Tests/Converters/ObjectToImageConverterTests.cs index ee7858968..646e12535 100644 --- a/Fluent.Ribbon.Tests/Converters/ObjectToImageConverterTests.cs +++ b/Fluent.Ribbon.Tests/Converters/ObjectToImageConverterTests.cs @@ -41,4 +41,35 @@ public void TestDynamicResource() Assert.That(drawingGroup.Children.Cast<GeometryDrawing>().Select(x => x.Geometry.ToString()), Is.EquivalentTo(((DrawingGroup)((DrawingImage)Application.Current.FindResource(fluentRibbonImagesApplicationmenuResourceKey)).Drawing).Children.Cast<GeometryDrawing>().Select(x => x.Geometry.ToString()))); } -} \ No newline at end of file + + private class DummyProvider : IServiceProvider + { + object IServiceProvider.GetService(Type serviceType) + { + return null; + } + } + + [Test] + public void TestStaticResourceSequnece() + { + var fluentRibbonImagesApplicationmenuResourceKey = (object)"Fluent.Ribbon.Images.ApplicationMenu"; + + var expressionType = typeof(ResourceReferenceExpressionConverter).Assembly.GetType("System.Windows.ResourceReferenceExpression"); + + var expression = Activator.CreateInstance(expressionType, fluentRibbonImagesApplicationmenuResourceKey); + + var converter = new ObjectToImageConverter(); + + converter.ProvideValue(new DummyProvider()); + + var convertedValue = StaticConverters.ObjectToImageConverter.Convert(new object[] + { + expression, // value to convert + new ApplicationMenu() // target visual + }, null, null, null); + + Assert.That(convertedValue, Is.Not.Null); + Assert.That(convertedValue, Is.InstanceOf<Image>()); + } +}