简体   繁体   中英

WPF ControlTemplate - default style

I want to use the default style of buttons and just want to add a Grid and Stackpanel with 2-3 Bindings. When i add the ControlTemplate in my Style all Trigger-, Border-, ...settings are overwritten. How can i just add my Grid/Stackpanel/Bindings while using the rest of the default settings?

<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>

The purpose of a ControlTemplate is to define how a Control must be displayed. You can't have a ControlTemplate based on another ControlTemplate (it wouldn't make sense). What you can do is take the default ControlTemplate and modify it at your will.

The default ControlTemplate for Button can be found here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM