如何检查标签背景
if([Label has any color don't do anything]){
if (turn == Players.p1)
{
label.Background = Brushes.Red;
turn = Players.p2;
}
else
{
label.Background = Brushes.Green;
turn = Players.p1;
}
}
答案 0 :(得分:1)
您可以通过检查其Background
,或者可能是null
Transparent
。
所以要么
if (label.Background == null)
或者
if (label.Background == Brushes.Transparent)