我在WPF Windows XAML中定义了一个静态资源:
<Window.Resources>
<Image x:Key="MyImage" Source="../Icons/img.png" Width="16" Height="16" Stretch="None" />
</Window.Resources>
我想要将它使用两次:
<Grid>
<Button Content="{StaticResource MyImage}" RenderOptions.BitmapScalingMode="NearestNeighbor" RenderOptions.EdgeMode="Aliased" />
</Grid>
...
<Grid>
<Button Content="{StaticResource MyImage}" RenderOptions.BitmapScalingMode="NearestNeighbor" RenderOptions.EdgeMode="Aliased" />
</Grid>
但它只在最后一个按钮上显示为按钮图像。第一个按钮没有图像。
当我移除第二个按钮时,它可以用于第一个按钮。如何多次使用StaticResource?Visual Studio GUI设计器在两个按钮上都显示图像。