我正在尝试在Common.xaml中定义一个通用的Width资源,该资源将被不同的控件共享,如下所示:
我会将其翻译为:我随后在ButtonStyle.xaml中定义的按钮样式中使用它。
有人有任何想法我做错了什么吗?提前感谢。
<GridLength x:Key="CommonWidth">20</GridLength>
我会将其翻译为:我随后在ButtonStyle.xaml中定义的按钮样式中使用它。
<Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Width" Value="{DynamicResource CommonWidth}"/>
....
</Style>
在App.xaml中的ResourceDictionary定义中,Common.xaml在ButtonStyle.xaml之前被包含。当我运行应用程序(.Net3.5 SP1上),我得到了以下异常:
'20' is not a valid value for property 'Width'.
有人有任何想法我做错了什么吗?提前感谢。