You are mixing serialization schemes. Serialization of the constructor (for which it is intended DesignerSerializationVisibility) has nothing to do with the instance serialization mechanism (which works ShouldSerializeXXX, among many other things).
DesignerSerializationVisibility.Content a string ( ). :
Visible. , Content . :
public class MyControl : Control
{
public class SomeOptions
{
public string Option1 { get; set; }
public string Option2 { get; set; }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public SomeOptions Options { get; private set; }
public string Foo { get; set; }
}
, , :
this.myControl1.Foo = "value";
this.myControl1.Options.Option1 = "option1";
this.myControl1.Options.Option2 = "option2";
, , ; Content , ( SomeOptions), .
, , Content string. string , . Visible, ( ).
, , ( ) . - DefaultValue . , , , ( , , ), :/p >
[DefaultValue("foo")]
public string Foo { get; set; }
, Foo "foo", .