CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

BusinessListBase questions

rated by 0 users
Not Answered This post has 0 verified answers | 4 Replies | 1 Follower

Not Ranked
12 Posts
kosta_t posted on Thu, May 3 2012 11:33 PM

Hi,

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:

  • clone the item (business object) being dropped
  • make the cloned item dirty
  • add the cloned item to the target list
  • remove the item from the source list
    • I had to implement a new Remove' method in the target list to clear the deleted list in the source list.
    • This is important because I don't want the 'removed' item to be deleted from the db when/if the list is saved.

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?

All Replies

Top 10 Contributor
1,772 Posts

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 CslaContrib Coordinator

Not Ranked
12 Posts

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?

 

Top 10 Contributor
1,772 Posts

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.

 

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
12 Posts

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.

Page 1 of 1 (5 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems