模板(Template)是控件另一种样式 它和样式(style)不同的是它允许已有的控件进行组合新的一个控件样式
那么先看一下最简单Template代码
xaml代码
<Button Content="Button" Height="" HorizontalAlignment="Left"
Margin="44,30,0,0" Name="button1" VerticalAlignment="Top" Width="" >
<Button.Template>
<ControlTemplate>
<Border BorderThickness="" BorderBrush="#FF6969FF">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF6F97FF" Offset="" />
<GradientStop Color="#FF0021FF" Offset="0.574" />
<GradientStop Color="#FF6C7BFF" Offset="" />
</LinearGradientBrush>
</Border.Background>
<TextBlock Text="按钮" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="Lime"></TextBlock>
</Border> </ControlTemplate>
</Button.Template>
</Button>
效果图