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

TestProject.zip
0.15MB

▶ CustomEntry.cs

namespace TestProject
{
    /// <summary>
    /// 커스텀 엔트리
    /// </summary>
    public class CustomEntry : Entry
    {
    }
}

 

728x90

 

▶ App.xaml.cs

using Microsoft.Maui.Platform;

namespace TestProject;

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

    #region 생성자 - App()

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

        MainPage = new MainPage();

        Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping
        (
            nameof(IView.Background),
            (handler, view) =>
            {
                if(view is CustomEntry)
                {
#if ANDROID
                    handler.PlatformView.SetBackgroundColor(Colors.Red.ToPlatform());
#elif IOS
                    handler.PlatformView.BackgroundColor = Colors.Red.ToPlatform();
                    handler.PlatformView.BorderStyle     = UIKit.UITextBorderStyle.Line;
#elif WINDOWS
                    handler.PlatformView.Background = Colors.Red.ToPlatform();
#endif
                }
            }
        );
    }

    #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">
    <StackLayout
        HorizontalOptions="Center"
        VerticalOptions="Center">
        <Label Text="Label" />
        <Button
            Margin="0,10,0,0"
            Text="Button" />
        <local:CustomEntry
            Margin="0,10,0,0"
            MinimumWidthRequest="100" />
    </StackLayout>
</ContentPage>
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요