Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Button click on a listview cell

$
0
0

Hello,

We are developing an application that has a listview with cells that have buttons. Is there a way to identify which button of which cell was touched?

We a using a xaml to create de listview like that:

   <ListView x:Name="listView" RowHeight="150" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
        <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <StackLayout Orientation="Horizontal" VerticalOptions="FillAndExpand" BackgroundColor="White" Padding="10" Spacing="10">
                                <StackLayout Orientation="Vertical" Spacing="0">
                                    <RelativeLayout>
                                        <Image HeightRequest="110" WidthRequest="90" HorizontalOptions="Center" x:Name="driverPhoto" Source="{Binding UserPictureUrl}" />
                                        <Image HeightRequest="110" WidthRequest="90" HorizontalOptions="Center" x:Name="driverMask" Source="avatar_facebook_pequeno.png" />
                                    </RelativeLayout>
                                    <Label Text="{Binding UserMemberName}" Font="18" x:Name="userName" TextColor="#18bd9d" HorizontalOptions="CenterAndExpand"></Label>
                                </StackLayout>
                                <StackLayout Orientation="Vertical" Padding="10">
                                        <Label Text="{Binding UserBookedSeats, StringFormat='Lugares: {0}'}" Font="15" x:Name="userBookedSeats" TextColor="Gray" HorizontalOptions="StartAndExpand"></Label>
                                        <Label Text="{Binding PricePerSeat, StringFormat='Preço: R${0},00'}" Font="15" x:Name="PricePerSeat" TextColor="Gray" HorizontalOptions="StartAndExpand"></Label>
                                </StackLayout>
                                <StackLayout Orientation="Vertical" VerticalOptions="Center" HorizontalOptions="EndAndExpand" IsVisible="{Binding NeedApproval}">
                                        <Button BackgroundColor="#18bd9d" Text="√" Font="Bold, 18" HorizontalOptions="End" x:Name="buttonAccept" TextColor="White"></Button>
                                            <Button BackgroundColor="#EA9D3E" Text="X" Font="Bold, 18" HorizontalOptions="End" x:Name="buttonDeny" TextColor="White">
                                            </Button>
                                        </StackLayout>
                                    </StackLayout>
                                </ViewCell.View>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>

Viewing all articles
Browse latest Browse all 58056

Trending Articles