title: Retrieving ListView selected item value in Xamarin.Forms
body: <p>I'm developing/learning XamarinForms. I'm using Web Api to get values and use them to populate a ListView. Now I want to get current values on ItemSelected and store them for later use, but I don't seem to work it out. I'm using the MVVM.</p>
  
  <p>This is my ListView</p>
  
  <pre><code>&lt;ListView x:Name="ProfileDetails" ItemsSource="{Binding Profiles}"&gt;
      &lt;ListView.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;ViewCell&gt;
                  &lt;StackLayout  Margin="20,0,0,0" Orientation="Horizontal" HorizontalOptions="FillAndExpand"&gt;
                       &lt;Label Text="{Binding ProfileType}" VerticalTextAlignment="Center" HorizontalOptions="StartAndExpand" TextColor="LightGray"/&gt;
                      &lt;Label Text="{Binding ProfileChamber}" VerticalTextAlignment="Center" HorizontalOptions="StartAndExpand"  TextColor="LightGray"/&gt;
                      &lt;Label Text="{Binding ProfileWidhtMM}" VerticalTextAlignment="Center" HorizontalOptions="StartAndExpand" TextColor="LightGray"/&gt;
                      &lt;Label Text="{Binding ProfilePrice}" VerticalTextAlignment="Center" HorizontalOptions="StartAndExpand"  TextColor="LightGray"/&gt;
                   &lt;/StackLayout&gt;
               &lt;/ViewCell&gt;
           &lt;/DataTemplate&gt;
       &lt;/ListView.ItemTemplate&gt;                
   &lt;/ListView&gt;
  </code></pre>
  
  <p>This is the ViewModel</p>
  
  <pre><code>APIServices _apiServices = new APIServices();
  
  
  private List&lt;Profile&gt; _profiles;
  
  public List&lt;Profile&gt; Profiles
  {
      get { return _profiles; }
      set
      {
          _profiles = value;
          OnPropertyChanged();
      }
  }
  
  
  public ICommand GetProfilesCommand
  {
      get
      {
          return new Command(async () =&gt;
          {
              Profiles = await _apiServices.GetProfilesAsync(_accessToken);
          });
      }
  }
  </code></pre>
  
  <p>And this is my API request</p>
  
  <pre><code>public async Task&lt;List&lt;Profile&gt;&gt; GetProfilesAsync(string accessToken)
  {
      var client = new HttpClient();
  
      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
  
      var json = await client.GetStringAsync(Constants.GetProfilesUrl);
      var profiles = JsonConvert.DeserializeObject&lt;List&lt;Profile&gt;&gt;(json);
      return profiles;
  }
  </code></pre>
  
  <p>And this is the Model</p>
  
  <pre><code>public long Id { get; set; }
  public string ProfileType { get; set; }
  public int ProfileChamber { get; set; }
  public int ProfileWidhtMM { get; set; }
  public double ProfilePrice { get; set; } 
  </code></pre>