Wpf 资源字典中的动态资源
我已经创建了一个资源字典Wpf 资源字典中的动态资源,wpf,.net-3.5,Wpf,.net 3.5,我已经创建了一个资源字典 <ResourceDictionary x:Class="RPK.WindowsResources" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:RPK.ViewModel" xmlns:vw="c
<ResourceDictionary x:Class="RPK.WindowsResources"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:RPK.ViewModel"
xmlns:vw="clr-namespace:RPK.View"
xmlns:Converter="clr-namespace:RPK.Common">
<sys:String x:Key="Key_Combo_Big_Width">200</sys:String>
<Style x:Key="ComboBig">
<Setter Property="Control.Width" Value="{DynamicResource ResourceKey=Key_Combo_Big_Width}">
</Setter>
<Setter Property="Control.Height" Value="25"></Setter>
<Setter Property="Control.VerticalAlignment" Value="Center"></Setter>
</Style>
</ResourceDictionary>
200
我已经在app.xaml中将其作为合并词典应用
在我的window1.xaml中,我将此样式应用为
<ComboBox Name="Combo1" Style="{StaticResource ComboBig}"/>
当我运行代码时,我得到了这个错误
'200'不是属性“宽度”的有效值。
正确的方法是什么?Width属性是double,因此如果要为其分配特定类型的资源值,则需要使用double资源
<sys:Double x:Key="Key_Combo_Big_Width">200</sys:Double>
<Style x:Key="ComboBig">
<Setter Property="Control.Width" Value="{DynamicResource Key_Combo_Big_Width}">
</Setter>
<Setter Property="Control.Height" Value="25"></Setter>
<Setter Property="Control.VerticalAlignment" Value="Center"></Setter>
</Style>
200