1

I've got a project I've got to crank out (thanks to an employee quitting on the job before the deadline).

He'd been working in WPF. The interface looked cool, but it never was able to collect data from the company's old data access DLLs. (Rewriting the DLLs is a great idea, but not feasible in the short time left by the deadline) Collecting data was the whole point!

The project was thrown at me, but I'm no WPF developer. I've been told to make it work with WinForms, which is what I know. I had a WinForm interface cranked out in a few hours, and it looks every bit as good as the WPF version ...and I know what it is doing. WPF involves voo-doo I haven't learned yet.

There are things used in the WPF project that I need to get a grasp of what they do, and I do not have time to completely redesign it all.

The Business Logic Layer returns an ObservableCollection to the WPF interface.

The WPF interface takes the ObservableCollection and stores it in a CollectionViewSource using its Source parameter.

OK, I'm immediately thinking DataGridView control and using the DataSource parameter from it.

Am I on track?

What was the point of the IEditableCollectionView? Is it necessary? And if not, should I just remove all references to it?

H.B.
  • 166,899
  • 29
  • 327
  • 400

2 Answers2

2

ObservableCollection, CollectionViewSource etc. are important in the WPF's MVVM (MVC...+) scheme. You could drop them but you could certainly reuse them in a WinForms project. It might actually be better to do so to retain the clean separation between UI and data.

You could also hang on to them and use them as "more standard" collections which would simply result in a little bit of unnecessary overhead. And since meeting your deadline is of utmost importance, this might be the way to go.

Paul Sasik
  • 79,492
  • 20
  • 149
  • 189
  • Paul, your idea is technically better, and it has been marked as the answer ...especially for others who stroll in here. But, Josh's idea was faster to implement, so that's what my code uses right now. ;) –  Sep 10 '11 at 15:22
1

The observable collection is used so that other controls can participate when the collection is added to, removed, or refreshed. This helps keep the entire UI in sync. As far as the IEditableCollectionView, it raises the INotifyPropertyChanged event so that the controls on the WPF form automatically update when a property in the collection is updated.

If you are doing this in WinForms, you just need to raise events when your collection has changed.

Josh
  • 10,352
  • 12
  • 58
  • 109
  • Josh, wasn't sure how to mark the answer. I actually implemented your idea, but I think Paul's idea is a better technique - I just don't have time for it. –  Sep 10 '11 at 15:21