【发布时间】:2022-02-25 23:08:57
【问题描述】:
我有一个通过 style= 使用我自己的主题的按钮
我是这样使用的:
<Button Background="#844eff" Style="{StaticResource PosButtonTheme}" Content="Return&#x0a;Sale" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,44,0,0" />
我的主题代码如下所示:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style BasedOn="{StaticResource {x:Type Button}}"
TargetType="{x:Type Button}"
x:Key="PosButtonTheme">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<StackPanel
Margin="0,0,0,0">
<Border Width="62" Height="62">
<Border.Background>
<LinearGradientBrush StartPoint ="0,0" EndPoint ="1,2">
<GradientStop Color= "{TemplateBinding Property=Background}" Offset="0.0"/>
<GradientStop Color= "#FFFFAF" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Border.Clip>
<RectangleGeometry RadiusX="7" RadiusY="10" Rect="0,0,62,62"/>
</Border.Clip>
<Grid>
<StackPanel>
<TextBlock Text= "{TemplateBinding Property=Content}" TextAlignment="Center" Foreground="White" FontSize="14" FontFamily="Barlow Semi Condensed SemiBold" FontWeight="SemiBold" Margin=" 0,15,0,0"/>
</StackPanel>
</Grid>
</Border>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
“{TemplateBinding Property=Content}”在 TextBlock 中工作正常,但“{TemplateBinding Property=Background}”似乎什么也没做,它总是黑色或 #000000
有什么想法吗?
【问题讨论】:
-
在哪里定义 BackGround 属性?