2011-02-08 6 views
1

「テキスト」を「コンテンツ」プロパティとして含み、ATTRIBUTEとしてシリアル化する必要があるが、むしろ通常のテキスト要素サンプルC#XAMLのコンテンツフィールドのシリアル化

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

    } 

私はXamlServices & XamlWriterを使用していたが、結果は、任意の解決策と同じですか?

+0

TextElementの基本クラスはありますか? –

答えて

0

はDesignerSerializationOptionsAttributeとTextプロパティを飾るお試しください:

[DesignerSerializationOptions(DesignerSerializationOptions.SerializeAsAttribute)]

参照:

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

XmlAttributeAttributeのみのXmlSerializerシリアル化に影響を与えます。

+0

ありがとうございます。 – Chandimal

+0

この作品はありましたか? –