I'm working with Windows Forms designer. It serializes properties of type Color as known name whenever possible. I need it to serialize such properties always as RGB, because I need it later for interop with other system, which can deserialize only from RGB values. Is there a way to serialize Color properties always as RGB values?
+3
A:
Here's how I solved a similar problem. Hope it helps.
<System.Xml.Serialization.XmlIgnore()> _
Public Property LineColor() As Color
Get
Return mLineColor
End Get
Set(ByVal value As Color)
mLineColor = value
End Set
End Property
Public Property LineColorArgbString() As String
Get
Return ColorAsString(mLineColor)
End Get
Set(ByVal value As String)
mLineColor = ParseColorArgbString(value)
End Set
End Property
Troy Moon
2009-08-21 15:45:59
I had to use DesignerSerializationVisibilityAttribute instead of XmlIgnoreAttribute, but your idea did the trick. Thanks Troy
Przemaas
2009-08-23 21:24:41