0

我如何在这里检查标签的背景

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;
                    }
    }
4

1 回答 1

1

您可以通过检查它是否为空Background来检查它null,或者它可能是Transparent

所以要么

if (label.Background == null)

或者

if (label.Background == Brushes.Transparent)
于 2013-04-03T09:02:21.607 回答