Anybody written a TypeConverter for a custom Style class?

S

Sky

Hello (again!):

Been working all weekend on trying to get a grip on what happens under the
hood with WebControl.ControlStyle property versus WebControl.Style array...
And think I am getting somewhere...except for a couple more hitches to work
out. (Famous last words, no?)

What I am trying to do is work with a custom Style class that has Margin,
Padding, Text-Align, etc...

That part has correctly compiled, and I was able to wire it into a custom
control by adding to the control:

protected override Style CreateControlStyle() {

return (XActStyle) new XActStyle(ViewState);

}


To expose it in the IDE's property panel, I did:
[TypeConverter(typeof(ExpandableObjectConverter))]

public new XActStyle ControlStyle {get {return
(XActStyle)base.ControlStyle;}} //base.ControlStyle;


Works great: finally am starting to feel that it is looking more like what I
want in the IDE, where the CSS values are not all over the Property Panel
(ForeColor, etc) but grouped together under a Typed Style expandable class.

Now...The problem is that when I put values into this via the IDE, they are
not serialized/persisted to the HTML behind the control...
I suspect that it is that I need a TypeConverter for this.

Q: Could someone tell me if that guess is right/wrong before I spend hours
and hours looking up how to make a TypeConverter for such a complex
structure (ie: is there a base TypeConverter that I can build onto rather
than trying to figure out by what magic MS was able to combine BorderStyle
BorderColor, etc. with Style["Border"], etc....

Q: If someone has already built a TypeConverter that I can refer to to get a
leg up, could you post it/guide me to it?

Q:When I get it to work.....with a little help from someone ;-) ... I assume
that it will still not be addressible via HTML attribute tags -- unless I
expose all these properties directly (ie TextAlign {get{return
ControlStyle.TextAlign;....}} just as MS did -- which would bring me right
back to where I was trying to get away from (Style/Position properties as
base properties of the control, rather than neatly tucked away as sub
properties of ControlStyle accessible only via an
ExpandableObjectConverter... So my question is, would there be any way
that someone can think of that I can TypeConvert the Style attribute to
populate this ControlStyle, and viceversa?
Q: Failing that being possible/feasible... would the properties be
accessible via Html by the "-" Syntax -- ie something like <MyControl
ControlStyle-TextAlign="right" ControlStyle-BorderStyle='dashed'> Obviously
this is not at all what I want either -- but I ask for about this for
...ugh...'academic?' reasons...



Again, thanks so much for all the help :)
Sky
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top