I'm guessing you haven't implemented INotifyPropertyChanged on your Items class yet.
Up vote 1 down vote favorite share g+ share fb share tw.
I'm having an issue when I try to pass the selectedIndex of my list from my "List" screen. On my List screen I have the following binding: Code Behind: lbPrograms. ItemsSource = App.ViewModel.
Items; XAML: In my detail screen I look up using the selectedIndex value: App.ViewModel.Refresh(); DataContext = App.ViewModel.Itemsindex. NValDictionary; However, since I can't figure out how to just update a value in my iEnumerable collection I have been removingAtindex and then re-adding to the collection. So can anyone tell me, how do use update an existing element in my collection?
If not, can I pass the programId (that is in my binding) instead of the selectedIndex as the indexes are getting all messed up after the Delete/Add functionality. Please Advise. UPDATE: After speaking in several forums I should clear up that I am implement INotifyChanged Event on my properties in my object.
Basically the following snippet of code is my current issue: private void FavBtn_Click(object sender, EventArgs e) { foreach (var item in App.ViewModel. Items) { if ((item. CurrentProgram == true) && (item.
ProgramId! = index)) { item. CurrentProgram = false; } if (item.
ProgramId == index) { item. CurrentProgram = true; } } When I run this everything looks to be ok. However, when I navigate to another page, I re-load the object and the changes are lost.
It is almost like I need to save them before navigating, however, if I do a item.Save(); I get duplicates in my list. Windows-phone-7 link|improve this question edited Dec 13 '10 at 17:43 asked Dec 13 '10 at 1:41Jeff V1,4311133 96% accept rate.
I'm guessing you haven't implemented INotifyPropertyChanged on your Items class yet. Implementing this will allow updates made in these objects to be updated through your data bindings. Here's a walkthrough on how to implement INotifyPropertyChanged.
How to: Implement the INotifyPropertyChanged Interface.
Mick - Thanks for that walk-through. Actually I was implementing the INotifyPropertyChanged on my class, however, in the example I was following along with they had a save event... (onishimura.com/2010/07/25/…) Every time I call the . Save on the class I get a new item instead of just an updated item.
I will re-write my class to mimic what is in the example above to see if that makes a difference. Thanks! – Jeff V Dec 13 '10 at 5:13 If the requirement is to be able to add items, rather than update items in your list you should use ObservableCollection for your collection.. which is basically just INotifyPropertyChanged for collections.
– Mick N Dec 13 '10 at 6:15 @Mick... Versus what? I'm not following what you are trying to tell me. I appreciate you trying to help me.
– Jeff V Dec 13 '10 at 17:45 @Mick - I need the ability to Add, Edit and Remove from the collection. Is an ObservableCollection what I need? – Jeff V Dec 13 '10 at 17:46 Yes, ObservableCollection allows your data binding to update when you change the collection including adds and deletes.
– Mick N Dec 13 '10 at 21:05.
Is App.ViewModel. Items of type ObservableCollection? If so, when you modify a property of one of the collection items and raise a property change event (via INotifyPropertyChanged) indicating the collection property that your ListBox.
ItemsSource is bound to, the DataTemplate bindings will do the rest.
Thanks for the link. See my above comment to Mick. – Jeff V Dec 13 '10 at 5:14.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.