I can't set padding
to 0
in items of CollectionView
in MAUI.
In this example, I use Data
and Data[i].Color
as follow:
<CollectionView
ItemsSource="{Binding Data}"
ItemSizingStrategy="MeasureFirstItem"
ItemsLayout="HorizontalList">
<CollectionView.ItemTemplate>
<DataTemplate>
<Button
Clicked="Button_Clicked"
WidthRequest="10"
HeightRequest="10"
BackgroundColor="{Binding Color}" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
My Buttons has Width
10 and Height
10, and there is space between my Buttons. Only set Button Width
more than 100 can I see no space between my Buttons, but 100 is too large.
I tried to set Padding
or Margin
in Button
, and WidthRequest
in CollectionView
, but it didn't work.
How can I remove the space?
I tried ItemSpacing:
<CollectionView.ItemsLayout>
<LinearItemsLayout
Orientation="horizonal"
ItemSpacing="0" />
</CollectionView.ItemsLayout>
But fail.