如何更新 ListView 中的 ListViewItem Windows Phone 8.1

How to update a ListViewItem in a ListView Windows Phone 8.1

我正在尝试更新 ListViewItem 中的文本,但找不到方法。

我修改了我使用的可观察集合,但 ListView 没有更新。我实现它的唯一方法是删除和添加相同的项目,但这会创建一个糟糕的动画(我删除了它,但它看起来也很糟糕)。

我的模特:

public class Feed : INotifyPropertyChanged
{
    public int idfeed { get; set; }
    public string message { get; set; }
    public string comments { get; set; }
    public string likes { get; set; }
    public string timestamp { get; set; }
    public string type { get; set; }
    public string iLiked { get; set; }
    public string next_id_comment { get; set; }
    public event PropertyChangedEventHandler PropertyChanged;
    public void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

修改绑定到 listviewitem 文本框的项目(模型)的 属性。确保包含 属性 的模型实现了 INotifyPropertyChanged。

这样做:

    private string message;
    public string Message 
    {
        get
        {
            return message;
        }
        set
        {
               message = value;
               NotifyPropertyChanged("Message");
        }

然后在数据模板中添加 属性 名称。