Vibrant discussion about CSLA .NET and using the framework to build great business applications.
I am implementing some WPF drag & drop functionality between 2 Lists (in seperate business objects).
After some experimentation I have the following logic in the drop event handler:
This works ok, but leaves the wpf controls hosting the source list seeing it as being dirty & enabling the save button on the view. This is because the Remove method triggers a notification to the WPF controls, but clearing the deleted list doesn't trigger anything.
If I could force the list to trigger a notification after clearing the deleted list, I could get the wpf controls properly synchronised with the list.
Surely this (ie moving an item from one list to another) is a fairly common scenario.
Is there a recommended pattern for this?
There is an alternate method. These lists do not know bout each other, right?
I would rather use LINQ to filter the rows available from the Source list in the ViewModel and not have to worry about the Source.DeletedList or dirty handling.
All in all, it is a UI filtering that you need!
Jonny Bekkum, Norway
Thanks for the reply, but I don't understand your answer.
The lists do not know each other, but obviously the drop handler (in the viewmodel) has access to both lists (obtained from the drop info).
The drop event is being handled in the viewmodel & I am relying on data binding to trigger events in the views (one for each list).
How do I apply UI filtering from the viewmodel?
Create a IList<botype> property an member variable in your ViewModel.
Create a filtered list lik this (assuming you have 2 lists: source and dest)
var myFilteredList= source.ToSyncList(c => !(dest.Any(p => p.Id == c.Id)));
set the member varaible and raise propertychanged on the ViewModel property.
Unfortunately, the drop handler doesn't have access to the source viewmodel as that info is not supplied by the drag & drop process.
I could add a notify method to the business object that contains the list, because I can get to it (via the parent property of the list). Then the drop handler can call that method to force a sync once the drop is done.
I could alsothen create my own business & businesslist objects which contain the extra methods I am using & then subclass all my business objects & lists from my bases classes. That would wrap things up a little better.
Still, I waslooking for a more elegant / generic solution.