locked
Problems with ObservableCollection 'Update Items' RRS feed

  • Question

  • I have the code like this:

    _post = new ObservableCollection<Wall_Post>();
    _post.Add(new Wall_Post {Server = "ss"});
    
    lvMain.ItemsSource = _post;
    
    var item = _post.FirstOrDefault(i => i.Progress == "Visible");
    if (item != null)
    {
        item.Server = "111";
    }
    
    HttpResponseMessage message = await client1.PostAsync(url, content1);

    It works fine but when I need to update collection after HttpResponseMessage class like this:

    _post = new ObservableCollection<Wall_Post>();
    _post.Add(new Wall_Post {Server = "ss"});
    
    lvMain.ItemsSource = _post;
    
    HttpResponseMessage message = await client1.PostAsync(url, content1);
    
    var item = _post.FirstOrDefault(i => i.Progress == "Visible");
    if (item != null)
    {
        item.Server = "111";
    }

    Update don't work. I don't understant where is the Problem?

    Friday, September 13, 2013 3:34 PM

Answers

  • If you want that items at collection "_post" was updated when you modified it you needed implement INotifyPropertyChanged event.

    Friday, September 13, 2013 10:44 PM

All replies

  • Hello! Did you change _post collection in client1.PostAsync() method? 

    Also, you can ask in english forum, because this is russian speakers forum :)
    • Edited by Oleg Kurzov Friday, September 13, 2013 3:58 PM
    Friday, September 13, 2013 3:57 PM
  • Where I must to change _post collection?
    Friday, September 13, 2013 4:02 PM
  • No, I just ask you did you change this collection in client1.PostAsync or not?
    Friday, September 13, 2013 8:53 PM
  • If you want that items at collection "_post" was updated when you modified it you needed implement INotifyPropertyChanged event.

    Friday, September 13, 2013 10:44 PM