mirkaim
mirkaim

Reputation: 314

Label height in a CollectionView DataTemplate

Are the objects in the CollectionView or DataTemplate automatically padded or something? I can try to change the height of the label in a CollectionView but that only affects the label portion of it and not this extra padding which I would like to reduce. When I reduce label height, it just masks the text so I'm wondering if there is a way to reduce this padding or margin because it doesn't look great on PC.

The basic xaml code I have is this:

            <CollectionView
            x:Name="ResponseCollectionView"
            ItemsSource="{Binding Responses}"
            BackgroundColor="#404040"
            HeightRequest="200" 
            >

            <CollectionView.ItemTemplate>
                <DataTemplate x:DataType="{x:Type x:String}" >
                    <Label Text="{Binding .}" BackgroundColor="#303030" />
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>

And it looks like this: enter image description here

Upvotes: 0

Views: 188

Answers (1)

Jefffeely
Jefffeely

Reputation: 26

The padding issue is caused by the Windows implementation of CollectionView having an inaccessible Checkbox included in each line. The perceived padding is caused by the height of the line not reducing to smaller than the height of the checkbox. If you go in-depth into the live layout for the CollectionView you can see the checkbox and how it affects the height.

Upvotes: 1

Related Questions