简体   繁体   中英

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

 <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

you need to pass the data to your page. This doesn't happen automatically

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

then in 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>  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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