为什么令牌无效?

时间:2019-05-17 10:18:00

标签: wpf background styles

在将样式背景的值设置为资源画笔时,我总是使令牌无效 稍后,我需要根据用户的颜色选择来更改此按钮的背景代码,例如,我创建了字体系列和实心画笔,但是当字体工作时,颜色衬套却无法使用,我不知道为什么。

<FontFamily x:Key="DefaultFont">News Gothic MT</FontFamily>
<SolidColorBrush x:Key="Empty" Color="#00d700"/>
        <!--Button Styles-->
        <Style x:Key="ButtonStyle_Empty" TargetType="Button">
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <SolidColorBrush Color="Black"/>
                </Setter.Value>
            </Setter>
            <Setter Property="Background" Value="{StaticResource EmptyRoom}"/>
            <Setter Property="BorderThickness" Value="2,3,2,1"/>
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="Height" Value="50"/>
            <Setter Property="Width" Value="125"/>
            <Setter Property="FontSize" Value="15"/>
            <Setter Property="FontFamily" Value="{DynamicResource DefaultFont}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="25" Background="{TemplateBinding Background}">
                            <Border.Effect>
                                <DropShadowEffect Color="Black" ShadowDepth="0" BlurRadius="0"/>
                            </Border.Effect>
                            <TextBlock Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStyle="{TemplateBinding FontStyle}"  HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

0 个答案:

没有答案