C#怎么动态改变TabItem的背景色
1个回答
展开全部
设定
Background 属性,
比如 item.Background = Brushes.Red;
更高级的例子:
void ChangeBackground(object sender, RoutedEventArgs e)
{
if (btn.Background == Brushes.Red)
{
btn.Background = new LinearGradientBrush(Colors.LightBlue, Colors.SlateBlue, 90);
btn.Content = "Control background changes from red to a blue gradient.";
}
else
{
btn.Background = Brushes.Red;
btn.Content = "Background";
}
}
上面的例子使用 LinearGradientBrush ,显示线性渐变
Background 属性,
比如 item.Background = Brushes.Red;
更高级的例子:
void ChangeBackground(object sender, RoutedEventArgs e)
{
if (btn.Background == Brushes.Red)
{
btn.Background = new LinearGradientBrush(Colors.LightBlue, Colors.SlateBlue, 90);
btn.Content = "Control background changes from red to a blue gradient.";
}
else
{
btn.Background = Brushes.Red;
btn.Content = "Background";
}
}
上面的例子使用 LinearGradientBrush ,显示线性渐变
参考资料: MSDN
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询