How to Notify ROL of Delete?

How to Notify ROL of Delete?

Old forum URL: forums.lhotka.net/forums/t/11134.aspx


simon posted on Tuesday, February 07, 2012

I have a ListView (ROL) and DetailsView( BO).

in my Detailsview have a Delete Button that invoke  BO.Delee method directly.

according to http://www.lhotka.net/weblog/IAmWorkingOnMyUsingCSLANET30EbookAndWroteSomeContentThatIDontThinkImGoingToUseInTheBook.aspx

notify the ROL the Add and Update.  but how to  notify ROL list to remove any deleted item?

I use BeginSave() and how to raise the event in BO?

RockfordLhotka replied on Tuesday, February 07, 2012

The way to raise the event or notification is to put that code in the BeginSave callback handler. Make sure to check e.Error first. Or, if you are using ViewModelBase you can just override OnError and OnSaved to detect error and save completion scenarios.

You should know however, that using an event for notifcation often isn't a good idea because it can too easily lead to memory leaks. You can use that technique, but only if you know exactly how your events are being hooked and unhooked.

If you are using a UI framework that has a loosely coupled event notification system (like Prism and others) you can use their model for notifications.

If your UI model is a single-document scheme (like a browser model, etc) you can use a "changed flag" scheme like I do in the WpUI project in ProjectTracker 4.2.

Basically, you need to use or devise a publish/subscribe notification model that doesn't use strong references and therefore doesn't cause memory leaks.

Copyright (c) Marimer LLC