日期:2014-05-17 浏览次数:21902 次
<Button FontSize="16" FontWeight="Bold" x:Name="btnBackground" Background="AliceBlue">Click Me
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Button.Template>
</Button>
bool flag = true;
void btnBackground_Click(object sender, RoutedEventArgs e)
{
if (flag)
{
this.btnBackground.Background = new SolidColorBrush(Colors.Blue);
}
else
{
this.btnBackground.Background = new SolidColorBrush(Colors.AliceBlue);