Hi, Can I xml serialize the property of type Color? The following doesn't work: [TypeConverter(typeof(ColorConverter))] [XmlElement(typeof(string))] public Color TextColor { get; set; } How? -- thanks
"Dmitry Nogin" wrote in message news:%23csweF73HHA.5160@TK2MSFTNGP05.phx.gbl... > Can I xml serialize the property of type Color? OK, I did it. Looks ugly... private Color _textColor = SystemColors.WindowText; [DisplayName("Text Color")] [XmlIgnoreAttribute()] public Color TextColor { get { return _textColor; } set { _textColor = value; } } [XmlElement("TextColor")] [Browsable(false)] public string TextColorHtml { get { return ColorTranslator.ToHtml(_textColor); } set { _textColor = ColorTranslator.FromHtml(value); } }
"Dmitry Nogin" wrote in message news:%23csweF73HHA.5160@TK2MSFTNGP05.phx.gbl... > Hi, > > Can I xml serialize the property of type Color? > > The following doesn't work: > > [TypeConverter(typeof(ColorConverter))] > [XmlElement(typeof(string))] > public Color TextColor > { get; set; } What happens if you remove the two attributes? -- John Saunders [MVP]