WPF Reflections

I think I have (at last) the workaround that gets WPF to bind to objects from Linq (to SQL or Entities or anything…)

The problem is that Linq’s EntitySet class doesn’t implement INotifyCollectionChanged, so when you bind to an object that contains child collection classes you don’t get automatic notification of changes to your collection.

You basically have four choices:

Use a framework like CSLA (and I’m going to look a lot more closely at the v3 of CSLA which supports WPF)

Create another class (and all child classes) and copy data out of the EntitySet into the new class and put that in an ObservableCollection. Then when you save copy it back into a new Linq DataContext (and all the child classes) – do you think yuk like me?

Bind the control to the EntitySet’s GetNewBindingList(), which will dynamically update the control for you

Create a BindingSource object and set it’s DataSource to the EntitySet’s GetNewBindingList() call and then bind the control to the BindingSource

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your reply...

There was an error processing your information. Please try again later.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your reply...

About This Blog

Detailing the aspects of Windows Presentation Foundation that goes beyond the documentation, with real world experience.