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

TestProject.zip
0.15MB

▶ Employee.cs

namespace TestProject;

public class Employee
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Property
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region ID - ID

    /// <summary>
    /// ID
    /// </summary>
    public int ID { get; set; }

    #endregion
    #region 명칭 - Name

    /// <summary>
    /// 명칭
    /// </summary>
    public string Name { get; set; }

    #endregion
}

 

728x90

 

▶ EmployeeCollection.cs

namespace TestProject
{
    /// <summary>
    /// 직원 컬렉션
    /// </summary>
    public class EmployeeCollection : List<Employee>
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - EmployeeCollection()

        /// <summary>
        /// 생성자
        /// </summary>
        public EmployeeCollection()
        {
            Add(new Employee { ID = 1, Name = "홍길동" });
            Add(new Employee { ID = 2, Name = "김철수" });
            Add(new Employee { ID = 3, Name = "이영희" });
        }

        #endregion
    }
}

 

300x250

 

▶ 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:EmployeeCollection x:Key="EmployeeCollectionKey" />
    </ContentPage.Resources>
    <StackLayout
        HorizontalOptions="Center"
        VerticalOptions="Center"
        BindableLayout.ItemsSource="{StaticResource EmployeeCollectionKey}">
        <BindableLayout.ItemTemplate>
            <DataTemplate>
                <HorizontalStackLayout>
                    <Label Text="{Binding ID}" />
                    <Label
                        Margin="10,0,0,0"
                        Text="{Binding Name}" />
                </HorizontalStackLayout>
            </DataTemplate>
        </BindableLayout.ItemTemplate>
    </StackLayout>
</ContentPage>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요