我正在为我的所有图标使用 ResourceDictionary
,如下所示:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas x:Key="Icon.Refresh"
Width="32" Height="32"
Clip="F1 M 0,0L 32,0L 32,32L 0,32L 0,0">
<Path Width="28" Height="28"
Canvas.Left="2" Canvas.Top="2"
Stretch="Fill"
Data="..." />
</Canvas>
</ResourceDictionary>
和实际的 XAML:
<Button Content="{StaticResource Icon.Refresh}"
Height="40"
Width="40" />
这很好用,因为我的大多数按钮都是这个尺寸。但是当我想在较小的按钮上使用它时,它会溢出按钮:
<Button Content="{StaticResource Icon.Refresh}"
Height="30"
Width="30" />
有没有办法设置 StaticResource
的大小或其他任何聪明的事情?
最佳答案
我想你可以把 Canvas
在 <ViewBox>
里面以便它自动缩小。
关于c# - 在 StaticResource Canvas 中为 Path 设置不同的大小或自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22657239/