Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Donghuan-He/App.xaml.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
32 lines (28 sloc)
985 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| |
#if WINDOWS | |
using Windows.Graphics; | |
#endif | |
namespace WeatherApp; | |
public partial class App : Application | |
{ | |
const int WindowWidth = 480; | |
const int WindowHeight = 800; | |
public App() | |
{ | |
InitializeComponent(); | |
MainPage = new MainPage(); | |
Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow), (handler, view) => | |
{ | |
//设置界面宽高 | |
#if WINDOWS | |
var mauiWindow = handler.VirtualView; | |
var nativeWindow = handler.PlatformView; | |
nativeWindow.Activate(); | |
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow); | |
Microsoft.UI.WindowId windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(windowHandle); | |
Microsoft.UI.Windowing.AppWindow appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId); | |
appWindow.Resize(new SizeInt32(WindowWidth, WindowHeight)); | |
#endif | |
}); | |
} | |
} |