AGo*_*ame 13 wpf staticresource
我想做这样的事情:
资源字典
<Color x:Key="clrPrimary">#5381ac</Color>
<Color x:Key="clrSecondary">#20558a</Color>
<Style TargetType="Grid" x:Key="myGrid">
<Setter Property="Background" Value="{StaticResource clrPrimary"/>
</Style>
Run Code Online (Sandbox Code Playgroud)
获得例外:
'#FF5381AC' is not a valid value for property 'Background'.
Run Code Online (Sandbox Code Playgroud)
无法将其钉牢,任何人都能指出正确的方向吗?
Mat*_*ton 19
Background是一个Brush,而不是一个Color.您最好的选择是将"主要"和"次要"资源定义为画笔而不是颜色.
很确定你甚至可以将刷子从你现有的颜色上移开.
<SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource clrPrimary}" />
...
<Setter Property="Background" Value="{StaticResource PrimaryBrush}" />
Run Code Online (Sandbox Code Playgroud)
background属性需要刷子才能工作.
<Window.Resources>
<SolidColorBrush x:Key="clrPrimary" Color="#5381ac" />
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11792 次 |
| 最近记录: |