Observablecollection未在Win Store App中更新

时间:2013-09-14 08:30:03

标签: c#

我有代码,我需要更新observablecollection,但代码不起作用:

    _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";
}

在之前的排名中,有人回答我这个问题在等待运算符。谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

我认为问题是关于Server属性而不是ObservableCollection(我希望我是对的;)

Wall_Post是否实现了INotifyPropertyChanged? Wall_Post应该实现它,Server属性应该是这样的:

    public string Server
    {
        get { return this._server; }
        set
        {
            if (this._server != value)
            {
                this._server = value;
                if (this.PropertyChanged != null)
                {
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Server"));
                }
            }
        }
    }