简体   繁体   English

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

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

Here is my code这是我的代码

  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());
    }

and here is my Mynewpage Xaml code这是我的 Mynewpage Xaml 代码

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

and here is an image of the output enter image description here every thing seems fine,but I guess the problem lies in the way I am using binding这是 output 的图像 在此处输入图像描述一切似乎都很好,但我想问题出在我使用绑定的方式上

you need to pass the data to your page.您需要将数据传递到您的页面。 This doesn't happen automatically这不会自动发生

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

then in Mynewpage然后在Mynewpage

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

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

  Mycollection = data;

  this.BindingContext = this;
  ...
}

and get rid of this摆脱这个

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

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

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