简体   繁体   中英

WPF: ControlTemplate vs Style that Changes Template

Inside App.xaml I may have:

<Style TargetType="{x:Type Button}" x:Key="roundButton">
  <Setter Property="Template">
     <Setter.Value>
        <ControlTemplate Target="{x:Type Button}">
            bla bla bla...
        </ControlTemplate>
     </Setter.Value>
  </Setter>
</Style>

vs. just going

<ControlTemplate Target="{x:Type Button}" x:Key="roundButton">
    bla bla bla...
</ControlTemplate>

I'm confused, which should I use / what's the difference?

Using the Style you could also change other values of the button at the same time. Using the ControlTemplate you can only change the template. So which is appropriate?

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