private void ChangeBackground(RadButton button, bool applyTemplate)
{
if (button != null)
{
Brush backgroundBrushRed = new SolidColorBrush(Colors.Red);
Brush backgroundBrushGreen = new SolidColorBrush(Colors.Green);
Brush borderBrush = new SolidColorBrush(Colors.Black);
//pegar a cor acrual do botão,temos que ir ao background converter para solidcolorBrush e dps
//ver a propriedade Color
if ((button.Background as SolidColorBrush).Color==Colors.Red)
button.Background = backgroundBrushGreen;
else
button.Background = backgroundBrushRed;
button.BorderBrush = borderBrush;
if (applyTemplate)
{
ControlTemplate template = button.Template;
button.Template = null;
button.Template = template;
button.ApplyTemplate();
}
}
}
No comments:
Post a Comment