Swipe does not work for all items in the listview. ConverterParameter has something to do with that
pantelisGeo90 opened this issue · 5 comments
Hello, this is an incredible library.
While trying it out in my project I've found out that the converterParameter
on widthRequest
for the [context].View
has a bit impact on the functionality of the swiping.
I've copied the code from your MenuFitWidthConverter.cs
class in my project because it was throwing an error.
I am using Xamarin.Forms 3.4.0.1039999
I've copied your example from https://github.com/AndreiMisiukevich/ContextMenu/blob/master/ContextMenuSample/ContextMenuSample/Pages/MoveToDeletePage.xaml but i can see that some of my items in my listview do not swipe. The ones that are "stuck" it appears that they have a smaller height than the rest that are working.
Thank you in advance.
Please see gif attached and my code:
<ListView ItemsSource="{Binding Notifications}"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
HasUnevenRows="True"
SelectionMode="None"
SeparatorVisibility="None"
IsPullToRefreshEnabled="False"
RefreshCommand="{Binding RefreshNotificationsCommand}"
IsRefreshing="{Binding IsLoading}"
x:Name="NotificationItemsView"
>
<ListView.ItemTemplate>
<DataTemplate>
<!--Swipe to delete-->
<context:SwipeActionContextHolder MovedCommand="{Binding MarkAsReadCommand}">
<context:SwipeActionContextMenuView ForceCloseCommand="{Binding ForceCloseCommand}">
<context:SwipeActionContextMenuView.View>
<Frame BackgroundColor="#512DA8"
Margin="15,5"
Padding="20"
WidthRequest="{Binding Source={x:Reference NotificationItemsView},
Path=Width,
Converter={StaticResource MenuFitWidthConverter},
ConverterParameter='70'}"
CornerRadius="10"
>
<StackLayout Orientation="Horizontal"
HorizontalOptions="FillAndExpand"
Spacing="10">
<Label Text="Text text , blah blah" />
</StackLayout>
</Frame>
</context:SwipeActionContextMenuView.View>
<context:SwipeActionContextMenuView.ContextTemplate>
<DataTemplate>
<Frame Margin="15, 5"
IsClippedToBounds="true"
CornerRadius="10"
BackgroundColor="Red"
>
<StackLayout Padding="10, 0"
Margin="0, 5"
>
<Label Text="Dismiss"
TextColor="White"
FontAttributes="Bold"
VerticalOptions="CenterAndExpand"
HorizontalOptions="EndAndExpand"
/>
</StackLayout>
</Frame>
</DataTemplate>
</context:SwipeActionContextMenuView.ContextTemplate>
</context:SwipeActionContextMenuView>
</context:SwipeActionContextHolder>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
It works fine if i use a RepeaterView though. That's weird :S
@pantelisGeo90 hmmm
how about CollectionView ?
@pantelisGeo90 could you please build a small sample where I can "play" ?
Or better: fork my repo and apply update in your fork
@AndreiMisiukevich Thanks for your response.
Unfortunately I can't use CollectionView
because i am using Xamarin.Forms 3.4 and i think the collectionView was introduced in version 4. (i can't update because the behaviour of my app breaks as soon as i update to a higher version of xamarin.forms, something to do with the carousel, i'll either have to use a different carousel or stay at this version)
I'll stick with the RepeaterView
for now (Xamarin.CustomControls.RepeaterView) and update this comment when i'll have some more details regarding this.
Thanks 👍
closing for now