I am using CollectionView
for the horizontal listview. It is working fine in android but in ios, the items are showing on one top of another. Attaching a screenshot below:
XAML
<CollectionView
HeightRequest="30"
SelectionMode="Single"
SelectionChanged="ItemTapped"
ItemsSource="{Binding Items}"
x:Name="collectionview"
ItemsLayout="HorizontalList">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Margin="5">
<Label
TextColor="Black"
FontSize="Large"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"
Text="{Binding title}"/>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Xaml.cs
public async void ItemTapped(object sender, SelectionChangedEventArgs e)
{
var selectedItem = (e.CurrentSelection.FirstOrDefault() as MyModel);
if (selectedItem != null)
{
//Do action
}
}
Add below code in AppDelegate class on iOS and MainActivity class on Android, before calling Forms.Init:
Forms.SetFlags("CollectionView_Experimental");
Am I missing something in IOS?