3.8 Beta Silverlight ViewModelBase<T>3.8 Beta Silverlight ViewModelBase<T>
Old forum URL: forums.lhotka.net/forums/t/7872.aspx
Peran posted on Sunday, October 25, 2009
I have been testing a Csla Light ViewModelBase<EditableRootList>
ViewModelBase<T>.DoRemove(T item) does not make sense to me as the 'item' parameter should not be typed as the EditableRootList but as an item within the List.
Could the Model property be typed as T rather than object, to remove the need for casting?
Peran
RockfordLhotka replied on Sunday, October 25, 2009
Take a look at Beta 2 (just released) which should address this issue.Peran replied on Monday, October 26, 2009
Thanks, I'm finding your VM implementation excellent to work with and creating data maintenance screens with very little code.
I'm using an EditableRootList as my model bound to a silverlight DataGrid. I noticed that I was not receiving notifications of errors when Items within the list were saved. Does this approach sound reasonable?:
Make ViewModelBase.HookObjectEvents virtual
Extend the method in my ViewModel and unhook/hook Model.Saved and ((INotifyUnhandledAsyncException)Model).UnhandledAsyncException
Call ViewModelBase.OnError as appropriate from the hooked events.
Cheers
Peran
RockfordLhotka replied on Monday, October 26, 2009
That’s a good point Peran, I hadn’t put much thought into ERLB scenarios.
Really I think you are right to make HookObjectEvents() virtual
overall, as this opens up the possibility of handling other arbitrary events on
the model. Though if it is public I think it should probably be renamed to OnModelChanged().
I’ll make this happen.
http://www.lhotka.net/cslabugs/edit_bug.aspx?id=619
Thank you!
Peran replied on Thursday, November 05, 2009
Hi Rocky,
Now that ViewModelBase.Model is typed as T it would be nice to have ViewModelBase.OnModelChanged oldValue and newValue parameters typed as T aswell.
The ModelProperty.PropertyMetadata callback would need to cast the the values to T on the call to OnModelChanged.
Regards
Peran
RockfordLhotka replied on Thursday, November 05, 2009
Thanks Peran, you are absolutely correct about typing the oldValue
and newValue parameters.
Copyright (c) Marimer LLC