https://futuremix.org/2009/10/expandable-property-on-visual-studio-property-editor
TypeConverter(typeof(ExpandableObjectConverter))属性を持ったクラスまたは構造体をプロパティにすることで展開が可能になる。
またDesignerSerializationVisibility属性を指定しておかないと設定したプロパティが正常に保存されない。
参照元のコードはちょっとミスがあったので、修正版をここに書いておく。
public partial class UserControl1 : UserControl
{
private HogeSetting setting1;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public HogeSetting Setting1
{
get { return setting1; }
set { setting1 = value; }
}
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public class HogeSetting
{
private bool visible = true;
[DefaultValue(true)]
public bool Visible
{
get { return visible; }
set { visible = value; }
}
private string text = "";
public string Text
{
get { return text; }
set { text = value; }
}
}