■ MauiWinUIApplication 클래스의 OnLaunched 메소드를 사용해 시작시 윈도우 크기를 설정하는 방법을 보여준다. (UWP)
▶ Platforms/Windows/App.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
using Microsoft.UI; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using Windows.Graphics; using WinRT.Interop; namespace TestProject.WinUI; /// <summary> /// 앱 /// </summary> public partial class App : MauiWinUIApplication { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - App() /// <summary> /// 생성자 /// </summary> public App() { this.InitializeComponent(); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Protected #region MAUI 앱 생성하기 - CreateMauiApp() /// <summary> /// MAUI 앱 생성하기 /// </summary> /// <returns>MAUI 앱</returns> protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); #endregion #region 시작시 처리하기 - OnLaunched(e) /// <summary> /// 시작시 처리하기 /// </summary> /// <param name="e">이벤트 인자</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { base.OnLaunched(e); object currentWindow = Application.Windows[0].Handler.PlatformView; IntPtr windowHandle = WindowNative.GetWindowHandle(currentWindow); WindowId windowId = Win32Interop.GetWindowIdFromWindow(windowHandle); AppWindow appWindow = AppWindow.GetFromWindowId(windowId); appWindow.Resize(new SizeInt32(800, 600)); } #endregion } |