Omegaware
Omegaware

Reputation: 25

WPF Entity Framework binding to navigation property not updating

I have a viewmodel with a Customer property bound to an Entity Framework object. The customer object has multiple navigation properties to other tables. My view displays properly if there is already an existing record in one of the dependent tables and I can edit and save, but when I try to add a new object to the Customer property like:

Customer.BillingDetail = new CustomerBillingDetail();

The view will not bind to the new object even though the viewmodel Customer property is populated with a blank object. So when I go to save, none of the entered values are persisted to the viewmodel, it still has the blank object.

So, how do I get the view and viewmodel to communicate on the addition of a new object to the navigation property?

Is there something I'm missing in the viewmodel for tracking the property change of the Customer navigation properties?

Thanks, -Sid.

Upvotes: 0

Views: 1212

Answers (2)

Nogusta
Nogusta

Reputation: 919

I'm guessing your EF objects do not implement INotifyChanged and do not use ObservableCollections

Upvotes: 1

Manvinder
Manvinder

Reputation: 4591

Just clear me one one thing, when you bind the view with the values in customer object and make some changes in any of the binded control. Does that change persist in the database. If not then You must try to bind the property with TwoWay mode.

It helps to update your customer object from the binded control.

Upvotes: 0

Related Questions