我已经创建了一个行为,它可以很好地处理非集合属性,但是Blend设计器不能“看到”集合的默认值。例如:
//WORKS!! (Enabled defaults to "true" (good))
private bool enabled = true;
[Category("Physics"), Description("")]
public bool Enabled
{
get { return enabled; }
set
{
enabled = value;
}
}
//DOESN'T WORK! The collection is always blank unless I manually add the items to the collection
private List<Category> collisionCategories = new List<Category>() { Category.All };
[Category("Physics"), Description("")]
public List<Category> CollisionCategories
{
get { return collisionCategories; }
set
{
collisionCategories = value;
}
}为什么"Category.All“不在我的列表中?
发布于 2011-01-09 11:54:47
在Blend中,在你的集合属性的右边有一个小方块。如果它是全黑的,那么你的集合就有它的“默认值”,这是你设置的值。如果要重写集合属性的默认值,则必须指定要添加到空白集合中的项。然后,小方块将显示一个白色的轮廓。
这正是Blend中所有集合属性的工作方式,Visual Studio设计器也是如此。但请放心,如果用户没有为您的集合指定值,则将应用默认值。
发布于 2011-01-09 01:26:58
它的工作原理是这样的:
private List<Category> collisionCategories =
new List<Category>(new Category[] { Category.All });https://stackoverflow.com/questions/4634832
复制相似问题