【发布时间】:2012-12-03 20:28:08
【问题描述】:
我正在尝试在 Common.xaml 中定义一个常见的 Width 资源,该资源将由不同的控件共享,如下所示:
<GridLength x:Key="CommonWidth">20</GridLength>
然后我在 ButtonStyle.xaml 中定义的 Button 样式中使用它
<Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Width" Value="{DynamicResource CommonWidth}"/>
....
</Style>
Common.xaml 包含在 App.xaml 的 ResourceDictionary 定义中的 ButtonStyle.xaml 之前。当我运行应用程序(在 .Net3.5 SP1 上)时,出现以下异常:
'20' is not a valid value for property 'Width'.
有人知道我做错了什么吗?提前致谢。
【问题讨论】:
标签: wpf xaml resourcedictionary gridlength