Fixed the initial window size for Windows
This commit is contained in:
parent
2f72fc5e7f
commit
3055752940
@ -1,4 +1,12 @@
|
|||||||
namespace UI_MAUI;
|
using Microsoft.Maui.LifecycleEvents;
|
||||||
|
|
||||||
|
#if WINDOWS
|
||||||
|
using Microsoft.UI;
|
||||||
|
using Microsoft.UI.Windowing;
|
||||||
|
using Windows.Graphics;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace UI_MAUI;
|
||||||
|
|
||||||
public static class MauiProgram
|
public static class MauiProgram
|
||||||
{
|
{
|
||||||
@ -10,6 +18,25 @@ public static class MauiProgram
|
|||||||
{
|
{
|
||||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#if WINDOWS
|
||||||
|
builder.ConfigureLifecycleEvents(events =>
|
||||||
|
{
|
||||||
|
events.AddWindows(wndLifeCycleBuilder =>
|
||||||
|
{
|
||||||
|
wndLifeCycleBuilder.OnWindowCreated(window =>
|
||||||
|
{
|
||||||
|
var nativeWindowHandle = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
||||||
|
var win32WindowsId = Win32Interop.GetWindowIdFromWindow(nativeWindowHandle);
|
||||||
|
var appWindow = AppWindow.GetFromWindowId(win32WindowsId);
|
||||||
|
|
||||||
|
const int width = 1366;
|
||||||
|
const int height = 768;
|
||||||
|
appWindow.ResizeClient(new SizeInt32(width, height));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
builder.Services.AddMauiBlazorWebView();
|
builder.Services.AddMauiBlazorWebView();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user