Вы можете использовать CollectionView . Это гибкое и производительное представление для представления списков данных с использованием различных спецификаций макета.
в xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="App10.MainPage">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<!-- Place new controls here -->
<CollectionView ItemsSource="{Binding MySource}">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"
Span="2" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame Padding="10" WidthRequest="120" HeightRequest="120">
<Frame BackgroundColor="AliceBlue" WidthRequest="100" HeightRequest="100" HasShadow="True" CornerRadius="10" Padding="10" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" >
<Image Source="{Binding BgImageSource}" WidthRequest="100" HeightRequest="100" />
<Label Text="{Binding Title}" WidthRequest="100" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />
</Frame>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
</ContentPage>
в коде позади (или модели представления)
Я использовал Stati c данные только для демонстрации, вы можете заменить их своими собственными данными.
public class DataModel
{
public string Title { get; set; }
public string BgImageSource { get; set; }
}
public ObservableCollection<DataModel> MySource { get; set; }
public MainPage()
{
InitializeComponent();
MySource = new ObservableCollection<DateModel>() {
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
new DataModel(){Title ="Transatcions" ,BgImageSource="xxx"},
};
BindingContext = this;
}
Для получения дополнительной информации и использования CollectionView вы можете обратиться https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/collectionview/.