첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
0.15MB

▶ 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="local:MonkeyModel">
                <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"
                    Name="Baboon"
                    Location="Africa and Asia" />
                <local:MonkeyModel
                    ImageURL="https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Capuchin_Costa_Rica.jpg/200px-Capuchin_Costa_Rica.jpg"
                    Name="Capuchin Monkey"
                    Location="Central and South America" />
                <local:MonkeyModel
                    ImageURL="https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/BlueMonkey.jpg/220px-BlueMonkey.jpg"
                    Name="Blue Monkey"
                    Location="Central and East Africa" />
            </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 ImageURL}" />
                    <Label Grid.Column="2"
                        FontSize="16"
                        FontAttributes="Bold"
                        Text="{Binding Name}" />
                    <Label Grid.Row="1" Grid.Column="2"
                        VerticalOptions="End"
                        FontAttributes="Italic"
                        Text="{Binding Location}" />
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</ContentPage>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요