通过 winform 设计器中的自定义编辑器进行编辑时,StringDictionary 未正确序列化
我正在创建一个带有 StringDictionary 属性的用户控件。我使用以下代码在控件属性网格中显示此属性的自定义编辑器:
public partial class SomeUserControl : UserControl
{
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor("System.Diagnostics.Design.StringDictionaryEditor,System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing")]
public StringDictionary Items { get; set; }
public SomeUserControl()
{
Items = new StringDictionary();
InitializeComponent();
}
}
当我单击该属性时,设计器会正确显示在 winform 设计器中。但是,当我编辑这些值时,它们不会在表单中序列化。
我错过了什么吗?或者 StringDictionaryEditor 不支持它?
非常感谢。
I'm creating a user control with a StringDictionary property. I'm displaying a custom editor for this propery in the control property grid with the following code :
public partial class SomeUserControl : UserControl
{
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor("System.Diagnostics.Design.StringDictionaryEditor,System.Design", "System.Drawing.Design.UITypeEditor, System.Drawing")]
public StringDictionary Items { get; set; }
public SomeUserControl()
{
Items = new StringDictionary();
InitializeComponent();
}
}
The designer appears correctly in the winform designer when I click on the property. However, when I edit the values they are not serialized in the form.
Am I missing something? Or is it not supported by the StringDictionaryEditor?
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
StringDictionary 未实现 DesignerSerializationVisibility.Content 工作所需的 IList 和 ICollection。
StringDictionary does not implement IList and ICollection which are required for DesignerSerializationVisibility.Content to work.