【问题标题】:WPF: ControlTemplate vs Style that Changes TemplateWPF:ControlTemplate 与更改模板的样式
【发布时间】:2011-02-23 21:53:16
【问题描述】:

在 App.xaml 中我可能有:

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

对比刚去

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

我很困惑,我应该使用哪个/有什么区别?

【问题讨论】:

    标签: c# wpf xaml


    【解决方案1】:

    使用样式,您还可以同时更改按钮的其他值。 使用 ControlTemplate 您只能更改模板。 那么哪个合适呢?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多