New Posts New Posts RSS Feed: Update UI when change made to cache
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Update UI when change made to cache

 Post Reply Post Reply
Author
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Topic: Update UI when change made to cache
    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.
Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down