I'm trying to implement Undo function for my UWP app that has a listview that can be swiped to take action (like left swipe remove, right swipe archive). My xaml summary for the swipe listview is like this
<controls:SwipeListView.ItemTemplate>
<DataTemplate>
<Grid Visibility="{Binding HideForUndo, Converter={StaticResource BooleanNegationToVisibilityConverter}}">
SomeContents here...
</Grid>
</DataTemplate>
</controls:SwipeListView.ItemTemplate>
And the container style is like this
<controls:SwipeListView.ItemContainerStyle>
<Style TargetType="controls:SwipeListViewItem">
<Setter Property="TabNavigation" Value="Local"/>
<Setter Property="IsHoldingEnabled" Value="True"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="Padding" Value="0,0,0,0"/>
<Setter Property="MinHeight" Value="0"/>
</Style>
</controls:SwipeListView.ItemContainerStyle>
The problem is that after I hide the selected item, there will be some space between the items above and below the selected item. Only when the Undo timer expired and removed the selected item can the space be gone. I can see that the selected item has collapsed and the item below it did move up, but there is just some space.
I found a question that is similar to mine: How do you hide a ListView Item placeholder when it's DataTemplate child is collapsed? However it seems doesn't work for me even if I set MinHeigh
t and Padding
to 0
.
Edit:
After testing, I found that this is not related to ListView
but to the SwipeListView
.
The SwipeListView
added many other controls to it, only the highlighted part will be set to collapsed, other parts still visible.
SwipeListViewItem
? Could you share a minimal reproducible example that can reproduce your issue? For a normalListView
andListViewItem
, settingMinHeight
to0
should be able to work. - Jay ZuoSwipeListView
when left swipe? - Jay Zuo