views:

47

answers:

0

I've got a person object with properties:

public Person
{
    private string name;
    public string Name 
    { 
        get { return this.name; } 
        set { SetPropertyValue<string>("Name", ref this.name, value); }
    }

    [Association("Person-City"), Persistent("BillingCityID")]
    public cityType BillingCity { get; set; }
}

There's obviously more to this object, but that's the important part.

I bind these fields to UI elements the standard way, and technically the binding works fine except in one scenario. The scenario goes like this:

I have 2 addresses per person object, and in the UI they're on a tabcontrol. The BillingCity bound element (LookUpEdit) is on the second tab page of this tab control. When I do this:

  1. Open form
  2. Change Name bound textbox
  3. Change focus to some other control

I get an "Invalid Value" validation error on the Name textbox.

I did some digging, and it looks like SetPropertyValue<...> in the setter for Name is throwing an exception. I checked the exception and it has report that it's trying to set the BillingCity field on the Person to null.

Here's the catch; if I do this:

  1. Open form
  2. Change focused tabpage to the billing address tab page
  3. Change Name bound textbox
  4. Change focus to some other control

No problems. Everything works as it should.

What causes this problem? Obviously I don't know the details of SetPropertyValue as it's a method within the DevExpress toolset, but a bigger question: why would changing the focused tab (so that I can see the BillingCity bound control) work?