[Mono-bugs] [Bug 664835] New: Binding not started on when BindingContext null and BindingContextChanged raised

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Jan 16 17:53:25 EST 2011



           Summary: Binding not started on when BindingContext null and
                    BindingContextChanged raised
    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/ Safari/532.5

Binding doesn't start when BindingContext starts as null, then
BindingContextChanged is fired later.

Reproducible: Always

Steps to Reproduce:
The following unit test reproduces the problem:

public void Test_StartBindingOn_BindingContextChanged()
    TestDataSource dataSource = new TestDataSource();
    dataSource.IntProperty = 2;

    TextBox textBox = new TextBox();
    textBox.DataBindings().Add("Text", dataSource, "IntProperty"); // data
binding added before textBox is added to the form, and doesn't have a

    AssertEquals("2", textBox.Text, "Data binding started");

class TestDataSource
    public event EventHandler IntPropertyChanged;

    public const int IntPropertyDefaultValue = 5;
    int intProperty = IntPropertyDefaultValue;
    public int IntProperty
        get { return intProperty; }
            intProperty = value;
            if (IntPropertyChanged != null)
                IntPropertyChanged(this, EventArgs.Empty);
Actual Results:  
The unit test fails.

Expected Results:  
The unit test should pass as it does with ms.net

Code added to ControlBindingsCollection constructor:
    public ControlBindingsCollection (IBindableComponent control)
        bindable_component = control;

// ----- code added here ----- //
        EventDescriptor bindingContextChanged =
        if (bindingContextChanged != null)
            bindingContextChanged.AddEventHandler(control, new
                foreach (Binding binding in this)
// ----- code added here ----- //

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