如何在不关闭和打开应用的情况下更新 xamarin 中的数据?

问题描述

我有一种方法可以制作网格表并从网站获取 json 数据,但该网站的数据总是在变化。所以我需要关闭我的应用程序并重新打开它以进行数据刷新。如何在不关闭并重新打开我的应用程序的情况下执行此操作?如何刷新我的页面以更新数据?

public MainPage()
{
    InitializeComponent();
    GetTable();
}

public void GetTable()
{
    //It have my codes for create table and get datas from json
}

解决方法

尝试这样做..

public MainPage() {
  InitializeComponent();
  ValidateDatabase();
}




public async Task ValidateDatabase() {
  //It have my codes for create table and get datas from json

  await loadComponentsFromDatabase();
}


private async Task loadComponentsFromDatabase()

{
  // your operation to the database,and render it to the users

  // note that all components must render here and not in InitializeComponent.

  // so all your components must be visible= false until you are here and make 

  // visible = true

}