繁体   English   中英

从 azure 检索数据时,列表视图未显示我的结果

[英]List view not showing my Results when retrieving data from azure

这是我的代码

  public  List<string> Mycollection { get; set; } = new List<string>();
    public async void Button_Clicked(object sender, EventArgs e)
    {            
        string storageConnectionString = "mystring";           
        CloudStorageAccount storageAccount = DOTFORMS3.Common.CreateStorageAccountFromConnectionString(storageConnectionString);
        CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
        CloudTable table = tableClient.GetTableReference("tablename");
        TableQuery<CustomerEntity> tableQuery = new TableQuery<CustomerEntity>();
        foreach (CustomerEntity CustomerEntity in table.ExecuteQuery(tableQuery))
        {
            Mycollection.Add(CustomerEntity.NAME);
        }
        await Navigation.PushModalAsync(new Mynewpage());
    }

这是我的 Mynewpage Xaml 代码

 <ContentPage.BindingContext>
    <vm:Page1/>
</ContentPage.BindingContext>  
        <StackLayout> 
          <Label Text="koool"></Label>
        <ListView ItemsSource="{Binding Mycollection }">                
        </ListView>
    <Label Text="koool"></Label>
</StackLayout>

这是 output 的图像 在此处输入图像描述一切似乎都很好,但我想问题出在我使用绑定的方式上

您需要将数据传递到您的页面。 这不会自动发生

await Navigation.PushModalAsync(new Mynewpage(Mycollection));

然后在Mynewpage

public List<string> Mycollection { get; set; }

public Mynewpage(List<string> data)
{
  ...

  Mycollection = data;

  this.BindingContext = this;
  ...
}

摆脱这个

<ContentPage.BindingContext>
    <vm:Page1/>
</ContentPage.BindingContext>  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM