c# - Custom Property of a Custom User Control gets reset during rebuild -
i have following properties
[defaultvalue(true), category("behavior")] public bool enablebinding { get; set; } [defaultvalue(false), category("behavior")] public bool needapprove { get; set; }
when changed using designer , save rebuild, new values set through designer remain property needapprove. enablebinding getting reset false.
tried
1) designerserializationvisibility attributes, didnt work!
- visible
- hidden
- content
2) converting auto property full property worked. why? can not achieve without converting full property?
you should assign initial value enablebinding property within custom user-control constructor:
public partial class customusercontrol : usercontrol { public customusercontrol() { initializecomponent(); enablebinding = true; // !!! } [defaultvalue(true), category("behavior")] public bool enablebinding { get; set; } [defaultvalue(false), category("behavior")] public bool needapprove { get; set; } }
without initialized false
during deserialization.
Comments
Post a Comment