我的自定义类中有一个Color
属性。我们怎么能在Silverlight中发现Color是空的? 。在Wpf中,我们有属性IsEmpty
....
答案 0 :(得分:2)
Color
对象的默认值为#00000000
。
您可以从A,R,G,B值中进行检查。所有这些都是0。
以下可能性:
Color cl = new Color();//here A,R,G,B all are 0
然后:
Color cl;//same case
if(cl.A==0 && cl.R==0 && cl.G==0 && cl.B==0)
{
//do work here
}
然后:
Color cl = Colors.Transparent;//This one is easier for comparison like in following condition
if(cl == Colors.Transparent)
{
//do work here
}