arrow-left arrow-right brightness-2 chevron-left chevron-right circle-half-full dots-horizontal facebook-box facebook loader magnify menu-down RSS star Twitter twitter GitHub white-balance-sunny window-close
Editable Collection Adapter for WPF
1 min read

Editable Collection Adapter for WPF

This is an old post and doesn't necessarily reflect my current thinking on a topic, and some links or images may not work. The text is preserved here for posterity.

The screenshot below is of a sample WPF application that deals with editing a collection of items:

The editable collection

A few features:

  • You can make a batch of changes to the screen and hit "Save".
  • If you deleted items, you can click "Show deleted items" to make them visible again, then click Undo to rollback the deletion
  • The list on the left is bound to the same collection as the list on the right - the changes aren't written to the source until you click Save
  • If you change an item, it highlights in bold
  • If you change an item, you can undo the changes via the Undo button
  • If you add items to the original collection, they will appear on screen (the Remote Update button)

The object representing an individual row is just a simple POCO object with INotifyPropertyChanged support - it has no HasChanges property or similar. Likewise, the collection is just an ObservableCollection<T>.

This is all implemented with a mix of BindableLINQ and the Editable Object Adapter.


Note: This sample uses the Xceed WPF DataGrid control. If you have a license, you can use your license key when running the sample (just set it in App.xaml.cs). Alternatively, you can download a 45 day trial from the Xceed website.

Paul Stovell's Blog

Hello, I'm Paul Stovell

I'm a Brisbane-based software developer, and founder of Octopus Deploy, a DevOps automation software company. This is my personal blog where I write about my journey with Octopus and software development.

I write new blog posts about once a month. Subscribe and I'll send you an email when I publish something new.