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

TestProject.zip
0.15MB

▶ MauiProgram.cs

using Microsoft.Maui.LifecycleEvents;

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");
                    }
                )
                .ConfigureLifecycleEvents
                (
                    lifecycleBuilder =>
                    {
#if WINDOWS
                        lifecycleBuilder.AddWindows
                        (
                            windowsLifecycleBuilder => windowsLifecycleBuilder.OnWindowCreated
                            (
                                window =>
                                {
                                    window.SizeChanged += window_SizeChanged;
                                }
                            )
                        );
#endif
                    }
                );

            return builder.Build();
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////// Private

#if WINDOWS
        #region 윈도우 크기 변경시 처리하기 - window_SizeChanged(sender, e)

        /// <summary>
        /// 윈도우 크기 변경시 처리하기
        /// </summary>
        /// <param name="sender">이벤트 발생자</param>
        /// <param name="e">이벤트 인자</param>
        private static void window_SizeChanged(object sender, Microsoft.UI.Xaml.WindowSizeChangedEventArgs e)
        {
            ILifecycleEventService service = MauiWinUIApplication.Current.Services.GetRequiredService<ILifecycleEventService>();

            service.InvokeEvents(nameof(Microsoft.UI.Xaml.Window.SizeChanged));
        }

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

댓글을 달아 주세요