Nested object binding in XAML, Employee.AccountBalances prop change, ui does not


  • In my XAML, I have an object which binds to a sub-object of the main object from the view model:

    Text="{Binding Employee.AccountBalances.CompBalance, StringFormat='\{0\} days'}"

    During start-up, the Employee object is populated, and property change raised in the view model:

            public EmployeeInfo Employee
    get { return this._employee; }
    this._employee = value;
    if (PropertyChanged != null)
    PropertyChanged(this, new PropertyChangedEventArgs("Employee"));
    That all works great, and the text box displays the appropriate balance.  However, if I set the 'AccountBalances'
    property of the Employee (for example, this.Employee.AccountBalances = result.AccountBalances), the textbox value
    does not change.
    Shouldn't it change when that particular property of the Employee changes, since it's in the hierarchy and bound to the UI?
    If not, how do I get it to update when the AccountBalances property changes?  Thanks very much. 

    Thursday, April 19, 2012 6:23 PM


  • Found it, was raising property changed on Employee.AccountBalances, not Employee as I should have been.

    Friday, April 20, 2012 12:38 PM