Hello Fei Xu,
=================Update====================
System.AccessViolationException when using SwipeView in a CollectionView on Windows System.AccessViolationException when using SwipeView in a CollectionView on Windows This is a known issue. System.AccessViolationException when using SwipeView in a CollectionView on Windows This is a known issue. See MAUI github links: System.AccessViolationException when using SwipeView in a CollectionView on Windows This is a known issue. See MAUI github links: System.AccessViolationException when using SwipeView in a CollectionView on Windows - back again #9540
SwipeView throw exception on windows
And this known issue can not be solved now. Please don't use SwipeView in a CollectionView before this issue is solved.
Then I test with ListView, when you are running in windows platform with following code, this error do not show it and you can scroll it successfully without add heightrequest like Collectionview, but SwipeView do not show in window platform.
<ContentPage.Resources>
<Style TargetType="StackLayout">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="LightSkyBlue" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ContentPage.Resources>
<StackLayout>
<Button Text="scool"></Button>
<ListView x:Name="cvScores" Margin="5" ItemsSource="{Binding Scores}" HasUnevenRows="True" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<SwipeView>
<SwipeView.RightItems>
<SwipeItems >
<SwipeItem Text="删除"
IconImageSource="appicon.png"
BackgroundColor="LightPink"
Command="{Binding Source={x:Reference cvScores}, Path=BindingContext.DeleteCommand}"
CommandParameter="{Binding}" />
</SwipeItems>
</SwipeView.RightItems>
<Grid Padding="5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border Grid.RowSpan="2" StrokeShape="RoundRectangle 10,10,10,10" >
<Image
Source="{Binding ImageUrl}"
Aspect="AspectFill"
HeightRequest="60"
WidthRequest="60" />
</Border>
<Label Grid.Column="1"
Text="{Binding Title}"
FontAttributes="Bold" />
<Label Grid.Row="1"
Grid.Column="1"
Text="{Binding Creator}"
FontAttributes="None"
VerticalOptions="End" >
</Label>
</Grid>
</SwipeView>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
Best Regards, Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.