【发布时间】:2021-09-07 15:42:05
【问题描述】:
我在Windows.Resources 标签中设置了我的Buttons 样式。一切正常,除了Content,没有显示。
<Window …>
<Window.Resources>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border CornerRadius="5" BorderThickness="1" BorderBrush="#989898"
Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="#0E121A" />
<Setter Property="Margin" Value="3" />
<Setter Property="Foreground" Value="White" />
</Style>
</Window.Resources>
<Grid>
…
<Button Grid.Row="0" Grid.Column="2" Content="Send"
Click="ButtonActivateLicense_OnClick" />
</Grid>
<Window>
【问题讨论】:
-
你的样式覆盖了默认模板但是没有对内容使用模板绑定,那么如果你不指定应该在哪里渲染呢?
标签: c# wpf xaml user-interface controltemplate