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

TestProject.zip
0.15MB

▶ MauiProgram.cs

namespace TestProject;

/// <summary>
/// MAUI 프로그램
/// </summary>
public static class MauiProgram
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Method
    ////////////////////////////////////////////////////////////////////////////////////////// Static
    //////////////////////////////////////////////////////////////////////////////// Public

    #region MAUI 앱 생성하기 - CreateMauiApp()

    /// <summary>
    /// MAUI 앱 생성하기
    /// </summary>
    /// <returns>MAUI 앱</returns>
    public static MauiApp CreateMauiApp()
    {
        MauiAppBuilder builder = MauiApp.CreateBuilder();

        builder.UseMauiApp<App>()
            .ConfigureFonts
            (
                fontCollection =>
                {
                    fontCollection.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                }
            );

        return builder.Build();
    }

    #endregion
}

 

728x90

 

▶ App.xaml

<Application x:Class="TestProject.App"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:TestProject">
    <Application.Resources>
        <ResourceDictionary>
            <Color x:Key="PrimaryColor">#512bdf</Color>
            <Color x:Key="SecondaryColor">White</Color>
            <Style TargetType="Label">
                <Setter Property="FontFamily" Value="OpenSansRegular"                />
                <Setter Property="TextColor"  Value="{DynamicResource PrimaryColor}" />
            </Style>
            <Style TargetType="Button">
                <Setter Property="Padding"         Value="14,10"                            />
                <Setter Property="BackgroundColor" Value="{DynamicResource PrimaryColor}"   />
                <Setter Property="FontFamily"      Value="OpenSansRegular"                  />
                <Setter Property="TextColor"       Value="{DynamicResource SecondaryColor}" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

 

300x250

 

▶ App.xaml.cs

namespace TestProject;

/// <summary>
/// 앱
/// </summary>
public partial class App : Application
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 생성자 - App()

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

        MainPage = new MainPage();
    }

    #endregion
}

 

반응형

 

▶ 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"
    BackgroundColor="{DynamicResource SecondaryColor}">
    <ScrollView>
        <Grid
            RowSpacing="25"
            RowDefinitions="Auto,Auto,Auto,Auto,*"
            Padding="{OnPlatform iOS='30,60,30,30', Default='30'}">
            <Label Grid.Row="0"
                HorizontalOptions="Center"
                SemanticProperties.HeadingLevel="Level1"
                FontSize="32"
                Text="헬로우, 월드!" />
            <Label Grid.Row="1"
                HorizontalOptions="Center"
                SemanticProperties.HeadingLevel="Level1"
                SemanticProperties.Description="Welcome to dot net Multi platform App U I"
                FontSize="16"
                Text=".NET 다중 플랫폼 앱 UI에 오신 것을 환영합니다." />
            <Label x:Name="counterLabel" Grid.Row="2"
                HorizontalOptions="Center"
                FontSize="18"
                FontAttributes="Bold"
                Text="현재 카운트 : 0" />
            <Button Grid.Row="3"
                HorizontalOptions="Center"
                SemanticProperties.Hint="클릭 횟수를 계산합니다."
                FontAttributes="Bold"
                Text="클릭해 주세요"
                Clicked="countButton_Clicked" />
            <Image Grid.Row="4"
                HorizontalOptions="Center"
                WidthRequest="250"
                HeightRequest="310"
                SemanticProperties.Description="손을 흔드는 귀여운 닷넷봇!"
                Source="dotnet_bot.png" />
        </Grid>
    </ScrollView>
</ContentPage>

 

▶ MainPage.xaml.cs

namespace TestProject;

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

    #region Field

    /// <summary>
    /// 카운트
    /// </summary>
    private int count = 0;

    #endregion

    //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 생성자 - MainPage()

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

    #endregion

    //////////////////////////////////////////////////////////////////////////////////////////////////// Method
    ////////////////////////////////////////////////////////////////////////////////////////// Private

    #region 카운트 버튼 클릭시 처리하기 - countButton_Clicked(sender, e)

    /// <summary>
    /// 카운트 버튼 클릭시 처리하기
    /// </summary>
    /// <param name="sender">이벤트 발생자</param>
    /// <param name="e">이벤트 인자</param>
    private void countButton_Clicked(object sender, EventArgs e)
    {
        this.count++;

        this.counterLabel.Text = $"현재 카운트 : {count}";

        SemanticScreenReader.Announce(counterLabel.Text);
    }

    #endregion
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요