Tag: WPF ControlTemplate
<Button Content="Button" Template="{x:Null}"/>
<StackPanel> <StackPanel.Resources> <ControlTemplate x:Key="TestTemplate" TargetType="Button"> <Border Background="Cyan"> <TextBlock Text="テスト"/> </Border> </ControlTemplate> </StackPanel.Resources> <Button Content="Button1" Template="{StaticResource TestTemplate}" /> <Button Content="Button2" Template="{StaticResource TestTemplate}" /> </StackPanel>
<StackPanel> <StackPanel.Resources> <ControlTemplate x:Key="TestTemplate" TargetType="Button"> <Border Background="{TemplateBinding Background}"> <TextBlock Text="{TemplateBinding Content}"/> </Border> </ControlTemplate> </StackPanel.Resources> <Button Content="Button1" Background="Cyan" Template="{StaticResource TestTemplate}" /> </StackPanel>
<StackPanel> <StackPanel.Resources> <ControlTemplate x:Key="TestTemplate" TargetType="Button"> <Border Background="{TemplateBinding Background}"> <ContentPresenter Content="{TemplateBinding Content}"/> </Border> </ControlTemplate> </StackPanel.Resources> <Button Content="Button1" Background="Cyan" Template="{StaticResource TestTemplate}" /> </StackPanel>