It took me a little while to spot what is happening. The reason for your problem is you are changing the reference to the
CurrentCustomer
on the
Customers
object in a way that won't re-bind the UI. To see what I mean:
Have
Customers
implement the
INotifyProperyChanged
Interface. I normally do the following:
public abstract class ViewModel: INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Then:
public class Customers : ViewModel
{
Customer _customer;
public Customer Customer
{
get { return _customer; }
set
{
if(_customer == value)
return;
_customer = customer;
NotifyPropertyChanged("Customer");
}
}
}
Then
DataContext = Customers;
And change your binding paths, the UI will now be notified if the
CurrentCustomer
object changes on the
Customers
instance