Xamarin.Forms iOS透明列表视图标题问题



我正在制作一个简单的listView,并且对iOS标头遇到了问题 - 我想让它透明,但问题是,ListView项目在标题下滑动。我想实现的是,标题将通过ListView项目滑动。

这就是现在的样子

这就是当前代码的样子:

                    <ListView  x:Name="SingleBeanView" 
                ItemsSource="{Binding Beans}" 
                IsGroupingEnabled="true"
                Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
                           BackgroundColor="Transparent">
                    <ListView.GroupHeaderTemplate>
                        <DataTemplate>
                            <ViewCell ios:Cell.DefaultBackgroundColor="Transparent" Height="52">
                                <Label Text="{Binding Heading}" TextColor="{StaticResource LightTextColor}" FontSize="Large" HorizontalOptions="Start" VerticalOptions="Start" Margin="15,10,0,0"/>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.GroupHeaderTemplate>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <StackLayout BackgroundColor="Transparent" Orientation="Vertical">
                                    <StackLayout Orientation="Horizontal">
                                        <Label Text="{Binding Field1}"/>
                                        <Label Text="{Binding Field2}"/>
                                        <Label Text="{Binding Field3}"/>
                                    </StackLayout>
                                </StackLayout>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>

不幸的是,如果在ListView中使用GroupHeader,则无法实现您的需求。这种效果是由Apple设计的。如果要修改,这需要更多关于自定义listView的事情和时间。

这是本机iOS的解决方案,您可以尝试使用自定义渲染器。

因此,最后的方法可能需要自定义单元才能实现它 - 细胞中的标头。那意味着您无法使用GroupHeaderTemplate

另一个讨论。

最新更新