在花时间记录后,我无法解决我的问题。
我在UserControl中有List我无法在设计时将它与自定义属性绑定。 Here is Design Screenshot with error
public partial class TagListControl : UserControl
{
private HashSet<string> _tags;
private List<string> _Tags;
//[Browsable(false)] // Hiding this Because It's Not working in
//[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public List<string> Tags
{
get {
_Tags = _tags.ToList();
return _Tags;
}
set {
value = value ?? new List<string>();
_Tags = value;
value.ForEach(x =>
{
string[] Tags = x.Split(',');
foreach (string Tag in Tags)
{
if (!string.IsNullOrEmpty(Tag))
{
_tags.Add(Tag.Trim());
}
}
_tags.Add(x);
});
}
}
[Browsable(true)]
public bool AllowMultipleTags
{
get;
set;
}
[Browsable(false)]
public int Count
{
get { return _tags.Count; }
}
public TagListControl()
{
InitializeComponent();
_tags = new HashSet<string>();
}
.....
}
有人可以向我解释如何让设计师为用户提供字符串列表作为可能的值吗?他们可以逐个添加字符串列表。