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

TestProject.zip
0.15MB

▶ OSTYpe.cs

namespace TestProject;

/// <summary>
/// OS 타입
/// </summary>
public enum OSType
{
    /// <summary>
    /// 안드로이드
    /// </summary>
    Android,

    /// <summary>
    /// iOS
    /// </summary>
    iOS,

    /// <summary>
    /// 맥 OS
    /// </summary>
    macOS,

    /// <summary>
    /// 타이젠
    /// </summary>
    Tizen,

    /// <summary>
    /// 윈도우즈
    /// </summary>
    Windows
}

 

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">
    <StackLayout
        HorizontalOptions="Center"
        VerticalOptions="Center">
        <Label x:Name="label1"
            HorizontalOptions="Center"
            FontSize="20"
            Text="안드로이드 또는 iOS 운영체제 입니다." />
        <Label x:Name="label2"
            HorizontalOptions="Center"
            FontSize="20"
            Text="타이젠 또는 윈도우즈 운영체제 입니다." />
    </StackLayout>
</ContentPage>

 

728x90

 

▶ MainPage.xaml.cs

using CommunityToolkit.Maui.Converters;

namespace TestProject;

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

    #region 선택 값 - SelectedValue

    /// <summary>
    /// 선택 값
    /// </summary>
    public OSType SelectedValue { get; set; }

    #endregion

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

    #region 생성자 - MainPage()

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

        SelectedValue = OSType.iOS;

        EnumToBoolConverter converter1 = new EnumToBoolConverter();

        converter1.TrueValues.Add(OSType.Android);
        converter1.TrueValues.Add(OSType.iOS    );

        this.label1.SetBinding
        (
            Label.IsVisibleProperty,
            new Binding("SelectedValue", converter : converter1)
        );

        EnumToBoolConverter converter2 = new EnumToBoolConverter();

        converter2.TrueValues.Add(OSType.Tizen  );
        converter2.TrueValues.Add(OSType.Windows);

        this.label2.SetBinding
        (
            Label.IsVisibleProperty,
            new Binding("SelectedValue", converter : converter2)
        );

        BindingContext = this;
    }

    #endregion
}

 

반응형

 

▶ MauiProgram.cs

using CommunityToolkit.Maui;

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>()
            .UseMauiCommunityToolkit()
            .ConfigureFonts
            (
                fontCollection =>
                {
                    fontCollection.AddFont("OpenSans-Regular.ttf" , "OpenSansRegular" );
                    fontCollection.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                }
            );

        return builder.Build();
    }

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

댓글을 달아 주세요