Custom object with collection in XAML
i'd able implement type of code in xaml:
<ns:myobject x:key="myob">
<ns:myobject.myitems>
<ns:myitem itemname="test" />
<ns:myitem itemname="test2" />
<ns:myobject.myitems>
</ns:myobject>
my class declarations follows:
public class myitem
{
public string itemname { get; set; }
public myitem(){}
}
public class myobject
{
public list<myitem> myitems { get; set; }
...
}
but when run this, error: "ag_e_parser_bad_property_value". if remove myitem declarations, this:
<ns:myobject x:key="myob">
<ns:myobject.myitems>
<ns:myobject.myitems>
</ns:myobject>
then app loads fine no error.
what's best way i'm trying do?
thanks.
john
a common problem when writing custom collection classes xaml usage not initializing empty collection part of class logic class holds collection property.
try adding:
public myobject() {
this.myitems = new list<myitem>();
}
i'm not positive problem because fix trying use implicit collection syntax, whereas in case using explicit tag myitems.
Silverlight > Programming Silverlight with .NET – General
Comments
Post a Comment