title: Xamarin - Refresh listview after Post
body: <p>I am developing a <strong>Xamarin Forms App</strong>, it has a tabbed page.  One of the tabs contains a <code>ListView</code> control showing data consumed from a Rest API.  If I tap the add button a modal shows where I can create new items and send post to the Rest API.  After success I pop the modal from navigation what leaves the <code>ListView</code> showing.  In my <code>ListView</code>, the last added item is not showing.</p>
  
  <p>How can I manage to refresh the <code>ListView</code> calling the Rest API after I add an item?</p>
  
  <p>Here is my XAML page: <em>BonosView.xaml</em></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ContentPage xmlns ="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:iconize="clr-namespace:FormsPlugin.Iconize;assembly=FormsPlugin.Iconize"
      x:Class="rodriguez.BonosView" x:Name="BonosView"
      Title="Bonos"&gt;
  
      &lt;ContentPage.Padding&gt;
          &lt;OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0" /&gt;
      &lt;/ContentPage.Padding&gt;
  
      &lt;ContentPage.Content&gt;
          &lt;StackLayout&gt;
              &lt;Label x:Name="BonosListMessage" IsVisible="false" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Text="No exixten bonos para mostrar"/&gt;
              &lt;ListView x:Name="BonosList" ItemTapped="ViewDetails" RowHeight="70" &gt;
                  &lt;ListView.ItemTemplate&gt;
                    &lt;DataTemplate&gt;
                          &lt;ViewCell&gt;
                              &lt;Grid&gt;
                                  &lt;Grid.Padding&gt;
                                      &lt;OnPlatform x:TypeArguments="Thickness" iOS="10,5" Android="10,5"/&gt;
                                  &lt;/Grid.Padding&gt;
                                  &lt;Grid.RowDefinitions&gt;
                                      &lt;RowDefinition Height="*"/&gt;
                                      &lt;RowDefinition Height="*"/&gt;
                                      &lt;RowDefinition Height="*"/&gt;
                                  &lt;/Grid.RowDefinitions&gt;
                                  &lt;Grid.ColumnDefinitions&gt;
                                      &lt;ColumnDefinition Width="Auto"/&gt;
                                      &lt;ColumnDefinition Width="*"/&gt;
                                  &lt;/Grid.ColumnDefinitions&gt;
  
                                  &lt;Label x:Name="monto" Text="{Binding Monto}" Style="{DynamicResource TitleListBono}" Grid.Row="0" Grid.ColumnSpan="2" LineBreakMode="NoWrap" HorizontalOptions="StartAndExpand"/&gt;
                                  &lt;Label x:Name="nombre" Text="{Binding nombreCompleto}" FontSize="Small" FontAttributes="Bold" Grid.Row="1" Grid.Column="0" HorizontalOptions="StartAndExpand"/&gt;
                                  &lt;Label x:Name="estado" Text="{Binding Estado}" FontSize="Small" Grid.Row="1" Grid.Column="1" HorizontalOptions="End" TextColor="Green"/&gt;
                                  &lt;Label x:Name="montoRD" Text="{Binding MontoRD}" FontSize="Small" Grid.Row="2" Grid.Column="0" HorizontalOptions="StartAndExpand"/&gt;
                                  &lt;Label x:Name="fecha" Text="{Binding fechaCompra, StringFormat='{0:dd-MMM-yyyy}'}" FontSize="Small" Grid.Row="2" Grid.Column="1" HorizontalOptions="End"/&gt;
                              &lt;/Grid&gt;
                          &lt;/ViewCell&gt;
                    &lt;/DataTemplate&gt;
                  &lt;/ListView.ItemTemplate&gt;
                &lt;/ListView&gt;
  
          &lt;/StackLayout&gt;
      &lt;/ContentPage.Content&gt;
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p>And here is the method I call to populate the list:</p>
  
  <pre><code>async void refreshData()
  {
      this.IsBusy = true;
      bonosLista = await manager.GetAll();  //obtaining bonos from Server
  
      if (bonosLista != null)
      {
          if (bonosLista.Count() &gt; 0)
          {
              BonosList.ItemsSource = bonosLista;
          }
          else
          {
              BonosList.IsVisible = false;
              BonosListMessage.IsVisible = true;
          }
      }
      else
      {
          await DisplayAlert("Error!", "Se ha producido un error en la conexión", "OK");
      }
  
      this.IsBusy = false;
  }
  </code></pre>
  
  <p>I would like to call that method after the modal pops.</p>