dotnet windows forms designtime:
Hello experts.
I have a class called VisualAspect. This class stores information about
how to draw things (backcolor, forecolor, font, ...). This class is
complete with a TypeConverter (which returns a constructor based
InstanceDescriptor), DefaultValue attributes on every public property,
and ShouldSerializeXXX and ResetXXX methods on properties that cannot
provide constant/integral properties.
This class is used by my user control, which simplistically is laid out
as such:
public class Grid : System.Windows.Forms.UserControl
{
// ctor/ other stuff
VisualAspect normal_aspect = new VisualAspect();
VisualAspect hottrack_aspect = new VisualAspect();
[DesignerSerializationVisibility(Content)] <- shortened, by u get it
public VisualAspect AspectNormal
{ get... set... }
[DesignerSerializationVisibility(Content)]
public VisualAspect AspectHotTrack
{ get... set... }
}
Now, the problem is, the Forms designer won't serialize any modified
properties properly.
Here is a snippet from a form's code that contains my user control.
void InitializeComponent()
{
VisualAspect visualAspect1 = new VisualAspect(); // not necessary-
already constructed !
visualAspect1.BackColor = Color.Red; // ok- I set this in the
property grid
Grid grid1 = new Grid(); // ok
grid1.Location = ... // ok
grid1.Size = ... // ok
// No meaningful assignment is ever made in the code above, because
visualAspect1 goes out of scope.
}
Any thoughts or pointers to a good ComponentModel tutorial would be
appreciated since MSDN docs on this topic are cryptic and incomplete.