C# 如何在列表视图内容页上自动刷新数据Xamarin
我在列表视图中添加数据,但我需要先关闭程序以显示数据。我应该添加什么来自动刷新内容页 课程C# 如何在列表视图内容页上自动刷新数据Xamarin,c#,xamarin,xamarin.forms,C#,Xamarin,Xamarin.forms,我在列表视图中添加数据,但我需要先关闭程序以显示数据。我应该添加什么来自动刷新内容页 课程 public class Cart : BindableObject { public string product_id { get; set; } public string name { get; set; } public string price { get; set; } public string image { get; set; } public
public class Cart : BindableObject
{
public string product_id { get; set; }
public string name { get; set; }
public string price { get; set; }
public string image { get; set; }
public string quantity { get; set; }
}
如果ViewModel用于创建Cart列表,则在运行时添加数据时,ListView将更新 例如:
public ObservableCollection<Cart > CartItems { set; get; }
CartItems.Add(new Cart(){...})
公共ObservableCollection CartItems{set;get;}
添加(新购物车(){…})
您是否尝试过类似于:YourListView.Refresh()?“自动刷新”是什么意思?当listview的Itemsource发生变化时更新listview,或者您正在寻找更新数据的方法(例如在轮询中)?更新listview如果我添加了新数据@AlessandroAlbino,我不知道该怎么办@QuentinCouderccan您可以显示您的代码。。Itemsource在代码中的绑定