I'm encountering an issue with a DrawingImage
not being visible in the designer or during run-time within a WPF application. Here's the setup:
MainWindow.xaml
<Window.Resources>
<ResourceDictionary Source="TestDictionary.xaml"/>
</Window.Resources>
<Button>
<Image Source="{StaticResource close_FILL0_wght400DrawingImage}"/>
</Button>
TestDictionary.xaml
<DrawingImage x:Key="close_FILL0_wght400DrawingImage">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,-960 V0 H960 V0 H-960 Z">
<DrawingGroup.Transform>
<TranslateTransform X="0" Y="960" />
</DrawingGroup.Transform>
<GeometryDrawing Brush="#FF000000" Geometry="F1 M960,960z M0,0z M256,-200L200,-256 424,-480 200,-704 256,-760 480,-536 704,-760 760,-704 536,-480 760,-256 704,-200 480,-424 256,-200z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
Despite setting the Source
of the Image
to {StaticResource close_FILL0_wght400DrawingImage}
, the DrawingImage
is not visible as expected.
Any insights or suggestions on what might be causing this visibility issue would be greatly appreciated. Thank you!
You Drawing looks far too complicated. Try something like this:
<DrawingImage x:Key="close_FILL0_wght400DrawingImage">
<DrawingImage.Drawing>
<GeometryDrawing Geometry="M0,0 L10,10 M0,10 L10,0">
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="2"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingImage.Drawing>
</DrawingImage>