2

I am trying to achieve CollectionView with right swipe for item deletion. I know how to do it in Xamarin, I read MAUI documentation and samples around SwipeView but it simply isn't there. This is what I have, tested on windows platform.

EDIT - I've put SwipeView into DataTemplete of CollectionView, but its not working either, check the sample.

EDIT2 - It work's on Android, probably on iOS too, so this looks like Windows feature.

<SwipeView
    Threshold="200">
    <SwipeView.RightItems>
        <SwipeItems>
            <SwipeItemView>
                <!--Delete icon-->
                <Frame 
                    Grid.Column="0"
                    VerticalOptions="Fill"                   
                    HorizontalOptions="Fill"
                    WidthRequest="88"
                    BackgroundColor="red">

                    <Grid VerticalOptions="Center" HorizontalOptions="Center">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <!--Delete-->
                        <Label 
                            Text="D"
                            FontSize="25" 
                            HorizontalOptions="CenterAndExpand"
                            VerticalOptions="CenterAndExpand" />
                    </Grid>
                </Frame>
            </SwipeItemView>
        </SwipeItems>
    </SwipeView.RightItems>

    <!-- Content of SwipeView-->
    <CollectionView 
        x:Name="fro_CollectionView"
        VerticalScrollBarVisibility="Always"
        SelectionMode="Single"
        VerticalOptions="Fill"
        HorizontalOptions="Fill"
        MinimumHeightRequest="5"
        ItemsSource="{Binding StockCards}">

        <CollectionView.ItemTemplate>
            <DataTemplate x:DataType="Models:StockCard">
                <Grid Padding="2">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Label Grid.Row="0" Grid.Column="0" Text="{Binding Name}"/>
                    <Label Grid.Row="0" Grid.Column="1" Text="{Binding Price}"/>

                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</SwipeView>

Link to sample project.

2
  • 3
    if you want to be able to swipe on an individual row, you would put the SwipeView inside your template, not surrounding the entire CollectionView
    – Jason
    Commented Dec 18, 2022 at 12:45
  • yes, I've done that, but it isn't working either. I will update sample project with this version
    – Kalixt
    Commented Dec 18, 2022 at 12:46

1 Answer 1

0

It's platform specific issue (windows), currently under development.

https://github.com/dotnet/maui/issues/6152

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.