Print Page | Close Window

Update UI when change made to cache

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1705
Printed Date: 28-Mar-2025 at 1:00pm


Topic: Update UI when change made to cache
Posted By: cjohnson84
Subject: Update UI when change made to cache
Date Posted: 01-Apr-2010 at 7:05am
I am working with DevForce Silverlight in a simple demo application.  In my demo app I display a Silverlight treeview control that is bound to an IEnumerable collection ("Facilities") that was returned from an EntityQuery.  I have modified the "Facility" partial class that was generated by the DevForce Object Mapper to inherit from my own interface ITreeViewNode in order to make the binding generic (we plan on ultimately binding many different types to the treeview).
 
For demo purposes I have now added a button control that will update the caption property of the selected node ("Facility") in the treeview when clicked.  If I examine the cache, I see that the caption property of the entity has indeed been changed.  What is the recommended way to keep the treeview control in sync with changes made to the collection/cache?
 
Do I need to re-fetch the data or I was thinking I could convert the IEnumerable collection into an ObservableCollection and then modify the partial entity classes generated by the DevForce Object Mapper to inherit from INotifyPropertyChanged.  If that is the case though I think I will need to modify every object that is modeled though.  Is this built-in to the DevForce model somehow that I can take advantage of?  I have to admit I am confused here with the DevForce model in the picture and any guidance would be appreciated.



Replies:
Posted By: IdeaBlade
Date Posted: 01-Apr-2010 at 11:15am
I would definitely started by converting the IEnumerable to an ObservableCollection, since that implements both INotifyPropertyChanged and INotifyCollectionChanged. That might solve your problem right there.

DevForce entities already implement INotifyPropertyChanged, via their inheritance from EntityWrapper.

Of course there's no guarantee that a given control -- in this case the Treecontrol that you're using -- actually listens for the available notifications and does something about it. If it doesn't, then you'll have to, and when notify, refresh the TreeControl yourself.


Posted By: cjohnson84
Date Posted: 02-Apr-2010 at 6:17am
Thank you for the feedback!  I was able to get this working by converting the IEnumerable returned from the EntityQuery to an ObservableCollection and then modifying the partial classes generated by the DevForce Object Mapper as I initially suspected.



Print Page | Close Window