简体   繁体   中英

Xamarin.Forms iOS transparent ListView heading issue

I'm making a simple listview and got a problem with iOS header - I want to make it transparent, but the problem is, that listview items are sliding under heading. What I want to achieve, is that heading will slide up with listview items.

This is how it looks now

And this is how current code looks like:

                    <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>

Unfortunately , if using GroupHeader in ListView , this can not achieve your want.This effect is designed by Apple . If want to modify ,this need more things and time to do about customing listview.

Here is a solution for native ios, you can have a try with custom renderer to do.However, after testing this can not work in Xamarin.

So the last way maybe need custom cell to realize it--Puttinng header in Cell . Then That means you can not use GroupHeaderTemplate .

Another discussion .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM