WPF ControlTemplate - 默认样式
WPF ControlTemplate - default style
我想使用按钮的默认样式,只想添加一个带有 2-3 个绑定的 Grid 和 Stackpanel。当我在我的样式中添加 ControlTemplate 时,所有 Trigger-、Border-、...设置都被覆盖。我怎样才能在使用其余默认设置的同时添加我的 Grid/Stackpanel/Bindings?
<Style x:Key="listbutton">
<Setter Property="Button.Height" Value="40"/>
<Setter Property="Button.Margin" Value="0,3"/>
<Setter Property="Button.Template">
<Setter.Value>
<ControlTemplate>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
ControlTemplate 的用途是定义必须如何显示控件。您不能拥有基于另一个 ControlTemplate 的 ControlTemplate(这没有意义)。您可以做的是采用默认的 ControlTemplate 并随意修改它。
可以找到 Button 的默认 ControlTemplate here
我想使用按钮的默认样式,只想添加一个带有 2-3 个绑定的 Grid 和 Stackpanel。当我在我的样式中添加 ControlTemplate 时,所有 Trigger-、Border-、...设置都被覆盖。我怎样才能在使用其余默认设置的同时添加我的 Grid/Stackpanel/Bindings?
<Style x:Key="listbutton">
<Setter Property="Button.Height" Value="40"/>
<Setter Property="Button.Margin" Value="0,3"/>
<Setter Property="Button.Template">
<Setter.Value>
<ControlTemplate>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
ControlTemplate 的用途是定义必须如何显示控件。您不能拥有基于另一个 ControlTemplate 的 ControlTemplate(这没有意义)。您可以做的是采用默认的 ControlTemplate 并随意修改它。
可以找到 Button 的默认 ControlTemplate here