https://bugzilla.novell.com/show_bug.cgi?id=664830
https://bugzilla.novell.com/show_bug.cgi?id=664830#c0 Summary: ITypedList.GetItemProperties() isn't used to get data source PropertyDescriptors Classification: Mono Product: Mono: Class Libraries Version: 2.6.x Platform: x86 OS/Version: Windows 7 Status: NEW Severity: Normal Priority: P5 - None Component: Windows.Forms AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1036 Safari/532.5 When data binding, ITypedList.GetItemProperties() isn't used to get data source PropertyDescriptors, which limits the ability to customize PropertyDescriptors. Reproducible: Always Steps to Reproduce: 1. Create a BindingList subclass that implements ITypedList and ITypedList.GetItemProperties to return a custom PropertyDescriptorCollection. Example below. 2. Bind to the list using a custom property from the custom MyPropertyDescriptorCollection (see sample class and custom logic below). For example, DataBindings.Add("Text", dataSource, "ChildList.CustomProperty"); class TypedList<T> : BindingList<T>, ITypedList { public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors) { return new MyPropertyDescriptorCollection( listAccessors == null ? typeof(T) : GetListElementType(listAccessors[listAccessors.Length - 1].PropertyType)); } Type GetListElementType(Type type) { return typeof(IEnumerable).IsAssignableFrom(type) ? ListUtil.GetListElementType(type) : type; } public string GetListName(PropertyDescriptor[] listAccessors) { return null; } } class MyPropertyDescriptorCollection : PropertyDescriptorCollection { public MyPropertyDescriptorCollection(Type objType) : base(null) { if (objType == null) { throw new ArgumentNullException("objType"); } ObjType = objType; foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(objType)) { Add(property); } Add(new CustomPropertyDescriptor("CustomProperty", "CustomValue")); } public Type ObjType { get; private set; } } Actual Results: Data binding will fail as the CustomProperty won't be found. Expected Results: Data binding should succeed, and 'CustomValue' should be set on the control's Text property. To fix, inside the Binding class change all: TypeDescriptor.GetProperties (manager.Current) to TypeDescriptor.GetProperties (manager.GetItemProperties()) Easy fix! -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. You are the assignee for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
