我已经使用资源字典在我的 WPF 应用程序中包含了 xaml 图标,并且我正在使用 ContentControl 在窗口上呈现资源图标。
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<ContentControl Content="{StaticResource appbar_database}" />
</StackPanel>
</MenuItem.Header>
现在,如何将样式应用于 ContentControl 内的图标?例如,将宽度设置为 24 像素。
编辑 1
这是我的资源字典的样子:
<ControlTemplate x:Key="appbar_database">
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="34" Height="38" Canvas.Left="21" Canvas.Top="19" Stretch="Fill" Fill="#FF000000" Data="F1 M 38,19C 47.3888,19 55,21.0147 55,23.5038L 55,25.5C 55,27.9853 47.3888,30 38,30C 28.6112,30 21,27.9853 21,25.5L 21,23.5C 21,21.0147 28.6112,19 38,19 Z M 55,52.5C 55,54.9853 47.3888,57 38,57C 28.6112,57 21,54.9853 21,52.5L 21,46.5C 21,48.9853 28.6112,51 38,51C 47.384,51 54.9921,48.9874 55,46.5039L 55,52.5 Z M 55,43.5C 55,45.9853 47.3888,48 38,48C 28.6112,48 21,45.9853 21,43.5L 21,37.5C 21,39.9853 28.6112,42 38,42C 47.384,42 54.9921,39.9874 55,37.5038L 55,43.5 Z M 55,34.5C 55,36.9853 47.3888,39 38,39C 28.6112,39 21,36.9853 21,34.5L 21,28.5C 21,30.9853 28.6112,33 38,33C 47.384,33 54.9921,30.9874 55,28.5038L 55,34.5 Z "/>
</Canvas>
</ControlTemplate>