첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
------------------------------------------------------------------------------------------------------------------------------------------------------
728x90
728x170

TestProject.zip
0.15MB

▶ 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:local="clr-namespace:TestProject">
    <ContentPage.Resources>
        <local:ImageSourceConverter x:Key="ImageSourceConverterKey" />
    </ContentPage.Resources>
    <CollectionView x:Name="collectionView">
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Grid
                    Padding="10"
                    RowDefinitions="Auto"
                    ColumnDefinitions="Auto,10,*">
                    <Image Grid.Column="0"
                        WidthRequest="60"
                        HeightRequest="60"
                        Aspect="AspectFill"
                        Source="{Binding ImageURL, Converter={StaticResource ImageSourceConverterKey}}" />
                    <StackLayout Grid.Column="2">
                        <Label
                            FontAttributes="Bold"
                            FontSize="16"
                            Text="{Binding Name}" />
                        <Label
                            VerticalOptions="End"
                            FontAttributes="Italic"
                            Text="{Binding Location}" />
                    </StackLayout>
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
        <CollectionView.EmptyView>
            <StackLayout
                HorizontalOptions="Center"
                VerticalOptions="Center">
                <Label
                    HorizontalOptions="Fill"
                    Margin="10,25,10,10"
                    HorizontalTextAlignment="Center"
                    FontSize="18"
                    FontAttributes="Bold"
                    Text="필터와 일치하는 결과가 없습니다." />
                <Label
                    HorizontalOptions="Fill"
                    HorizontalTextAlignment="Center"
                    FontSize="12"
                    FontAttributes="Italic"
                    Text="상세 필터를 사용하시겠습니까?" />
            </StackLayout>
        </CollectionView.EmptyView>
    </CollectionView>
</ContentPage>

 

728x90

 

▶ MainPage.xaml.cs

namespace TestProject;

/// <summary>
/// 메인 페이지
/// </summary>
public partial class MainPage : ContentPage
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 생성자 - MainPage()

    /// <summary>
    /// 생성자
    /// </summary>
    public MainPage()
    {
        InitializeComponent();

        List<Monkey> list = new List<Monkey>();
        
        for(int i = 0; i < 10; i++)
        {
            list.Add
            (
                new Monkey
                {
                    Name     = "Baboon",
                    Location = "Africa and Asia",
                    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"
                }
            );
        
            list.Add
            (
                new Monkey
                {
                    Name     = "Capuchin Monkey",
                    Location = "Central and South America",
                    ImageURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/40/Capuchin_Costa_Rica.jpg/200px-Capuchin_Costa_Rica.jpg"
                }
            );
        
            list.Add
            (
                new Monkey
                {
                    Name     = "Blue Monkey",
                    Location = "Central and East Africa",
                    ImageURL = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/BlueMonkey.jpg/220px-BlueMonkey.jpg"
                }
            );
        }

        //this.collectionView.ItemsSource = list;
    }

    #endregion
}

※ 프리뷰 버전 안드로이드 에뮬레이터에서 테스트하면 실행시 화면에 아무 것도 표시되지 않으나 휴대폰에서는 정상적으로 실행된다.

728x90
그리드형(광고전용)
Posted by icodebroker
,