开发者

C# XAML serialization of content fields

I have a basic text drawing class that contains the "Text" as a "content" property as well as it needs to be serialized as an ATTRIBUTE, but rather it returns as a normal text element like Sample

[ContentProperty("Text")]
public class TextElement
{ [XmlAttribute("Text")]
    public string Text
    {
        get {开发者_StackOverflow return textBase.Text;  }
        set { textBase.Text = value; }

    }

I have used XamlServices & XamlWriter but the results is the same, Any solutions ?


Try decorating the Text property with the DesignerSerializationOptionsAttribute:

[DesignerSerializationOptions(DesignerSerializationOptions.SerializeAsAttribute)]

See:

http://msdn.microsoft.com/en-us/library/system.windows.markup.designerserializationoptionsattribute.aspx

The XmlAttributeAttribute only affects XmlSerializer serialization.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜