开发者

WPF: ControlTemplate vs Style that Changes Template

开发者 https://www.devze.com 2023-02-13 14:16 出处:网络
Inside App.xaml I may have: <Style TargetType=\"{x:Type Button}\" x:Key=\"roundButton\"> <Setter Property=\"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开发者_如何学JAVA / 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消