Alan
Alan

Reputation: 2086

Setting Color of DynamicResouce Icons in WPF

I am working with the MaterialDesign Icon pack which has a single XAML with a bunch of Canvas items declared such as:

<Canvas x:Key="appbar_3d_obj" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
    <Path Width="40" Height="40" Fill="{DynamicResource BlackBrush}" Canvas.Left="18" Canvas.Top="18" Stretch="Fill"  Data="F1 M 18,21.7037L 43.9259,18L 58,25.4074L 58,54.2963L 32.8148,58L 18,49.1111L 18,21.7037 Z "/>
</Canvas>

Then in the MainWindow.xaml I have:

<Button Content="{DynamicResource appbar_3d_obj}" Margin="55,400,707,21" />

The issue I have is that while they render properly after compiling, in the Designer you can't see them as the stroke is transparent / undefined. I could set Fill="Black" in the Icons.xaml file, but it seems I should learn how to do it the right way :)

How can I set the color so I can see the icons during design time?

Upvotes: 0

Views: 846

Answers (1)

Jeff R.
Jeff R.

Reputation: 1521

Hard to know how to answer for sure with the small code example you posted but have you tried simply defining the BlackBrush in the resources for either the the MainWindow's XAML (or the Canvas's)?

<Window ...>
    <Window.Resources>
        <SolidColorBrush x:Key="BlackBrush" Color="Black"/>
    </Window.Resources>
...
</Window>

Upvotes: 1

Related Questions