首先,我想感谢你们所有的精彩输入。我必须承认 - StackOverflow一直是最好的同伴导师资源,因此它为我提供了更多的知识,比......“大学”中的4年。谢谢!Silverlight 4 - 通过XAML声明/填充控件的集合属性?
我正在使用具有属性的控件,该属性是对象的集合。
public class UserParameter
{
string DisplayName { get; set; }
string Property { get; set; }
string Type { get; set; }
}
public class ParameterBuilder: UserControl
{
private ObservableCollection<UserParameter> parameters;
//alright - this is really dependency property.
//described as property just for simplicity.
public ObservableCollection<UserParamter> Parameters
{
get { return this.parameters; }
set { this.parameters = value; }
}
}
所以这个问题的肉是想弄清楚如何在Xaml中创建这个集合。例如:
<custom:ParameterBuilder Name="Parameter">
<custom:ParameterBuilder.Parameters>
<custom:UserParameter DisplayName="Test 0" Property="Size" Type="String"/>
<custom:UserParameter DisplayName="Test 1" Property="Value" Type="Decimal"/>
</custom:ParameterBuilder.Parameters>
</custom:ParameterBuilder>
这是可能的,如果是这样,我该如何去做呢?