0
votes

Im working on styling up my ListView. In my ItemTemplate are only two Labels in a Stacklayout with Vertical Orientation. As you can see in the Picture there are some spacing between the two Labels. I dont want this space and have the Labels direct under each other. Has someone an advice?

ListView with Label-Background

<ListView x:Name="ItemList"
             ItemSelected="ItemList_ItemSelected"
             HasUnevenRows="True"
             IsGroupingEnabled="true" 
             GroupDisplayBinding="{Binding LongName}"
             GroupShortNameBinding="{Binding ShortName}"
             SeparatorVisibility="None">
            <ListView.GroupHeaderTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <StackLayout Orientation="Horizontal" 
                                         BackgroundColor="{StaticResource LightGreyColor}" 
                                         Padding="20,10,0,10">
                                <Label Text="{Binding LongName}"
                                       Style="{DynamicResource DateLabel}"/>
                            </StackLayout>
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.GroupHeaderTemplate>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <StackLayout Orientation="Vertical"
                                         Padding="20,10,0,10">
                                <Label Text="{Binding Name}"
                                       Style="{DynamicResource ItemTitleLabel}"
                                       BackgroundColor="Bisque"/>
                                <Label Text="{Binding Description}"
                                       Style="{DynamicResource SubTitleLabel}"
                                       BackgroundColor="Bisque"/>
                            </StackLayout>
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
2

2 Answers

0
votes

I remember that default spacing between items in StackLayout (and between rows in a Grid) is more than 0. If you want no space between items you can simply add Spacing="0" attribute in your StackLayout.

0
votes

StackLayout has a default Spacing of 10, you need to set it to 0 if you don't want the spacing between items.