Implement IEditableObject on ObjectInstance

Aug 31, 2010 at 2:17 PM


How about implementing the IEditableObject interface on ObjectInstance<TWrappedObjectType>? I think it's really easy, just forward the BeginEdit(), CancelEdit() and EndEdit() methods to the wrapped object (if it implements IEditableObject). This might be useful for example when using the DataGrid control with UpdateControls.NET.

By the way, good job Michael! UpdateControl .NET is a great library!

Coordinator
Aug 31, 2010 at 8:50 PM

Good idea. I'll go ahead and make that change.

In the mean time, you can use ViewModelBase for your view models that implement IEditableObject. ForView.Wrap() will ignore these objects, since they implement INotifyPropertyChanged themselves. Since it won't be wrapped, your IEditableObject implementation will be visible to WPF or Silverlight.

When using ViewModelBase, you have to wrap your property getters in either Get(() => property) or GetCollection(() => collectionProperty). This gives Update Controls the hook that it would otherwise get from the wrapper.

I created ViewModelBase because the wrapper hides System.ComponentModel.DataAnnotations attributes such as Display and Required.

Coordinator
Sep 1, 2010 at 3:43 AM

The change is complete. Please pull the source code and give it a try.

Thanks for the suggestion.

Sep 1, 2010 at 5:41 PM

Great, thank you!