Tenho o seguinte código na minha view
<ListView x:Name="MyListView"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding Items}"
ItemTapped="Handle_ItemTapped"
CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell x:Name="cell">
<StackLayout x:Name="item" Orientation="Horizontal" Margin="0,0,0,5" HeightRequest="110" BackgroundColor="White">
<BoxView WidthRequest="8" BackgroundColor="#381F72"/>
<Image Source="{Binding img}"/>
<StackLayout HorizontalOptions="FillAndExpand">
<Label Text="{Binding nome}"
FontSize="18"
FontAttributes="Bold"
TextColor="#381F72"
HorizontalOptions="CenterAndExpand"/>
<Label Text="{Binding QtdServicos}"
FontSize="14"
TextColor="#381F72"
HorizontalOptions="CenterAndExpand"/>
<StackLayout Orientation="Horizontal" Margin="0,15,0,0">
<StackLayout x:Name="Item" Orientation="Horizontal" HorizontalOptions="Start">
<Image Source="{Binding ok}"/>
<Label Text="{Binding Avaliacoes}"
FontSize="14"
TextColor="#03FD9B"
VerticalOptions="End"/>
</StackLayout>
<Button Text="CONTRATAR"
Padding="5"
Margin="0,0,10,0"
BackgroundColor="#03FD9B"
TextColor="White"
HeightRequest="20"
FontSize="10"
CornerRadius="5"
BindingContext="{Binding Source={x:Reference MyListView}, Path=BindingContext}"
Command="{Binding Path=BindingContext.ContratarCommand, Source={x:Reference ContactView}}"
CommandParameter="{Binding}"
HorizontalOptions="EndAndExpand"/>
</StackLayout>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
e a minha view model..
private Command<object> _ContratarCommand;
public Command<object> ContratarCommand => _ContratarCommand ?? (_ContratarCommand = new Command<object>(ContratarCommandExecute));
async void ContratarCommandExecute(object value)
{
try
{
// Aqui o VALUE vem a lista contendo todos os viewCell na tela com as suas respectivas propriedades.
await NavigationService.Current.NavigateTo(new ChatView(...,...));
}
catch (Exception ex)
{
await App.Current.MainPage.DisplayAlert("Entre em contato com nossa equipe de suporte!", ex.Message, "ok");
}
}
eu queria obter apenas o conteúdo da viewcell onde esta o botão clicado, e nao todos os itens da minha classe vinculada a listview no ItemsSource="{Binding Items}" tem como fazer isso, oque preciso mudar no meu código? desde já obrigado. meu primeiro projeto então me perdoem!