Forum Xamarin.Forms

listItem_ItemSelected doesn't work inside SwipeView

nonubittanonubitta Member ✭✭
edited April 2020 in Xamarin.Forms

This works:

    <ListView x:Name="lstItem" RowHeight="70" ItemSelected="lstItem_ItemSelected" SeparatorColor="Black">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                <StackLayout VerticalOptions="Center" Spacing="1" HorizontalOptions="StartAndExpand" Padding="20, 5, 15, 5">
                    <StackLayout Orientation="Horizontal" Spacing="1">
                        <Label TextColor="DarkBlue" Text="{Binding Name}" FontSize="18" ></Label>
                        <Label TextColor="DarkBlue" Text=" - " FontSize="18" ></Label>
                        <Label TextColor="DarkBlue" Text="{Binding itemCount}" FontSize="18" ></Label>
                        <Label TextColor="DarkBlue" Text=" items" FontSize="18" ></Label>
                    </StackLayout>
                    <StackLayout Orientation="Horizontal" Spacing="1">
                        <Label TextColor="DarkBlue" Text="Created on:" FontSize="12" ></Label>
                        <Label TextColor="DarkBlue" Text="{Binding CreatedOn}" FontSize="12" ></Label>
                    </StackLayout>
                </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

This does not:

        <ListView x:Name="lstItem" RowHeight="70" ItemSelected="lstItem_ItemSelected" SeparatorColor="Black">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <SwipeView HorizontalOptions="Fill">
                                <SwipeView.RightItems>
                                    <SwipeItems Mode="Reveal">
                                        <SwipeItem Text="Delete" BackgroundColor="Red" Invoked="DeleteItem_Clicked" CommandParameter="{Binding .}"></SwipeItem>
                                    <SwipeItem Text="Move" BackgroundColor="#A9A9A9" Invoked="MoveItem_Clicked" CommandParameter="{Binding .}"></SwipeItem>
                                    </SwipeItems>
                                </SwipeView.RightItems>
                            <StackLayout VerticalOptions="Center" Spacing="1" HorizontalOptions="StartAndExpand" Padding="20, 5, 15, 5">
                                    <StackLayout Orientation="Horizontal" Spacing="1">
                                        <Label TextColor="DarkBlue" Text="{Binding Name}" FontSize="18" ></Label>
                                        <Label TextColor="DarkBlue" Text=" - " FontSize="18" ></Label>
                                        <Label TextColor="DarkBlue" Text="{Binding itemCount}" FontSize="18" ></Label>
                                        <Label TextColor="DarkBlue" Text=" items" FontSize="18" ></Label>
                                    </StackLayout>
                                    <StackLayout Orientation="Horizontal" Spacing="1">
                                        <Label TextColor="DarkBlue" Text="Created on:" FontSize="12" ></Label>
                                        <Label TextColor="DarkBlue" Text="{Binding CreatedOn}" FontSize="12" ></Label>
                                    </StackLayout>
                                </StackLayout>
                            </SwipeView>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Best Answer

Answers

Sign In or Register to comment.