728x90
반응형
728x170
▶ MonkeyModel.cs
namespace TestProject;
/// <summary>
/// 원숭이 모델
/// </summary>
public class MonkeyModel
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 이미지 URL - ImageURL
/// <summary>
/// 이미지 URL
/// </summary>
public string ImageURL { get; set; }
#endregion
#region 명칭 - Name
/// <summary>
/// 명칭
/// </summary>
public string Name { get; set; }
#endregion
#region 서식지 - Location
/// <summary>
/// 서식지
/// </summary>
public string Location { get; set; }
#endregion
}
728x90
▶ MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="TestProject.MainPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=netstandard"
xmlns:local="clr-namespace:TestProject">
<CollectionView Margin="10">
<CollectionView.ItemsSource>
<scg:List x:TypeArguments="scg:KeyValuePair(x:String,local:MonkeyModel)">
<scg:KeyValuePair x:TypeArguments="x:String,local:MonkeyModel">
<x:Arguments>
<x:String>Baboon</x:String>
<local:MonkeyModel
ImageURL="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Papio_anubis_%28Serengeti%2C_2009%29.jpg/
200px-Papio_anubis_%28Serengeti%2C_2009%29.jpg"
Location="Africa and Asia" />
</x:Arguments>
</scg:KeyValuePair>
<scg:KeyValuePair x:TypeArguments="x:String,local:MonkeyModel">
<x:Arguments>
<x:String>Capuchin Monkey</x:String>
<local:MonkeyModel
ImageURL="https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Capuchin_Costa_Rica.jpg/200px-Capuchin_Costa_Rica.jpg"
Location="Central and South America" />
</x:Arguments>
</scg:KeyValuePair>
<scg:KeyValuePair x:TypeArguments="x:String,local:MonkeyModel">
<x:Arguments>
<x:String>Blue Monkey</x:String>
<local:MonkeyModel
ImageURL="https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/BlueMonkey.jpg/220px-BlueMonkey.jpg"
Location="Central and East Africa" />
</x:Arguments>
</scg:KeyValuePair>
</scg:List>
</CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid
Padding="10"
RowDefinitions="Auto,Auto"
ColumnDefinitions="Auto,10,Auto">
<Image Grid.Row="0" Grid.RowSpan="2" Grid.Column="0"
WidthRequest="60"
HeightRequest="60"
Aspect="AspectFill"
Source="{Binding Value.ImageURL}" />
<Label Grid.Column="2"
FontSize="16"
FontAttributes="Bold"
Text="{Binding Key}" />
<Label Grid.Row="1" Grid.Column="2"
VerticalOptions="End"
FontAttributes="Italic"
Text="{Binding Value.Location}" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage>
728x90
반응형
그리드형(광고전용)
댓글을 달아 주세요