Say I have a particular type that I want to make available to the Windows Forms designer...
public class Style
{
public CustomBrush Brush { get; set; }
}
And CustomBrush
is implemented like so...
public abstract CustomBrush
{
...
}
public SolidCustomBrush : CustomBrush
{
...
}
public GradientCustomBrush : CustomBrush
{
...
}
Is there a way at design time that I can choose from any of the types derived from CustomBrush
, instantiate an instance of the selected type, and modify it via the designer?
So far the only way I've though of to be able to do this is using an enum
enum BrushType
{
Solid,
Gradient
}
When the enum
changes, so does type underlying the Brush
property, but I don't like this approach...it's dirty!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…