[Mono-bugs] [Bug 664832] New: PropertyDescriptor.AddValueChanged not used for data binding, asms.net does.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Jan 16 17:27:22 EST 2011


https://bugzilla.novell.com/show_bug.cgi?id=664832

https://bugzilla.novell.com/show_bug.cgi?id=664832#c0


           Summary: PropertyDescriptor.AddValueChanged not used for data
                    binding, asms.net does.
    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: mono-bugs at lists.ximian.com
        ReportedBy: cvolzke at live.com.au
         QAContact: mono-bugs at lists.ximian.com
          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

EventDescriptor and not PropertyDescriptor.AddValueChanged when data binding,
as ms.net does.

This makes modifying the behaviour of hooking / unhooking events for properties
inconsistent between mono and ms.net.


Reproducible: Always

Steps to Reproduce:
1. Customize a PropertyDescriptor by implementing ICustomTypeDescriptor on the
data source, and returning a custom property in GetProperties.
2. Override AddValueChanged on your custom PropertyDescriptor.
3. Data bind to the custom property.

Actual Results:  
AddValueChanged is not called.
Custom value changed logic is not invoked.


Expected Results:  
AddValueChanged should be called.
Custom value changed should be invoked.


These changes fix the issue and causes the test above to pass.
Note that bug 651561 would also need to be fixed in order for these changes to
work correctly.

Code modified in Binding.GetPropertyChangedEvent to return PropertyDescriptor:
    PropertyDescriptor GetPropertyChangedEvent (object o, string property_name)
    {
        if (o == null || property_name == null || property_name.Length == 0)
            return null;

        PropertyDescriptor prop_changed_event = null;
        foreach (PropertyDescriptor event_desc in
TypeDescriptor.GetProperties(o))
        {
            if (event_desc.Name == property_name)
            {
                prop_changed_event = event_desc;
                break;
            }
        }
        return prop_changed_event;
    }

Line removed from PropertyManager:
    private EventDescriptor changed_event; // line removed

Code modified in PropertyManager.SetDataSource:
    internal void SetDataSource (object new_data_source)
    {
        if (prop_desc != null && data_source != null)                          
       // line added
            prop_desc.RemoveValueChanged(data_source,
property_value_changed_handler); // line added
        //if (changed_event != null)                                           
            // line removed
        //    changed_event.RemoveEventHandler (data_source,
property_value_changed_handler); // line removed

        data_source = new_data_source;

        if (property_name != null) {
            prop_desc = TypeDescriptor.GetProperties (data_source).Find
(property_name, true);
            if (prop_desc == null)
                return;

        if (prop_desc != null && data_source != null)                          
     // line added
        {                                                                      
     // line added
            property_value_changed_handler = new
EventHandler(PropertyValueChanged); // line added
            prop_desc.AddValueChanged(data_source,
property_value_changed_handler);  // line added
        }
        //changed_event = TypeDescriptor.GetEvents (data_source).Find
(property_name + "Changed", false);
        //if (changed_event != null) {
        //    property_value_changed_handler = new EventHandler
(PropertyValueChanged);
        //    changed_event.AddEventHandler (data_source,
property_value_changed_handler);
        //}
    }

-- 
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.


More information about the mono-bugs mailing list