[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


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

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


           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/4.1.249.1036 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:

[Test]
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
BindingContext
    Form.Controls.Add(textBox);

    Form.Show();
    Application.DoEvents();
    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; }
        set
        {
            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 =
TypeDescriptor.GetEvents(control)["BindingContextChanged"];
        if (bindingContextChanged != null)
        {
            bindingContextChanged.AddEventHandler(control, new
EventHandler(delegate
            {
                foreach (Binding binding in this)
                {
                    binding.Check();
                }
            }));
        }
// ----- 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