开发者

How to set the default value property for an object represented in XAML

开发者 https://www.devze.com 2022-12-18 03:05 出处:网络
Say i have an object like class Item { string Value {get;set;} } class MyClas开发者_开发技巧s { List<Item> Values {get;set;}

Say i have an object like

class Item
{
  string Value {get;set;}
}
class MyClas开发者_开发技巧s
{
    List<Item> Values {get;set;}
}

How can i make it so that when i'm using this object in XAML, i can set the value property like so.

<MyClass>
<Item>A</Item>
<Item>B</Item>
</MyClass>


Try this:

<MyClass>
    <MyClass.Values>
        <Item>A</Item>
        <Item>B</Item>
        <Item>C</Item>
    </MyClass.Values>
</MyClass>


Found the answer, i needed to put a [ContentPropertyAttribute] on!

0

精彩评论

暂无评论...
验证码 换一张
取 消