//遍历每个级别的控件,当控件类型为lbl 并且状态为2时,改变字体颜色为白。
foreach (UIElement element in uiControls)
{
if (element is Label)
switch (alermStatus)
{
case 2:
(element as Label).Foreground = new SolidColorBrush(Colors.White);
break;
default:
(element as Label).Foreground = new SolidColorBrush(Colors.Black);
break;
}
else if (element is Border && (element as Border).Child is Label) //如果该控件为border,border的子节点是lbl
{
Label lbl = (Label)(element as Border).Child;
switch (alermStatus)
{
case 2:
lbl.Foreground = new SolidColorBrush(Colors.White);
break;
default:
lbl.Foreground = new SolidColorBrush(Colors.Black);
break;
}
}
WPF遍历界面控件
最新推荐文章于 2024-08-23 07:15:00 发布