简体   繁体   English

如何使我的 MAUI 应用程序的 window 固定,因此无法调整大小或设置最小高度/宽度?

[英]How can I make the window of my MAUI app fixed, so not resizable or set a minimum height/width?

How can I set the size of the window in my MAUI Windows application to be fixed?如何在我的 MAUI Windows 应用程序中设置 window 的大小以进行修复? So the user can not resize the window.因此用户无法调整 window 的大小。 Or how is it possible to set a minimum height or width to the window?或者如何为 window 设置最小高度或宽度?

you can set OverlappedPresenter.IsResizable Property to false using handler api:您可以使用处理程序 api 将OverlappedPresenter.IsResizable 属性设置为 false:

public App()
{
        InitializeComponent();
#if WINDOWS
        SetWinNoResizable();
#endif
...
}

    public void SetWinNoResizable()
    {
        Microsoft.Maui.Handlers.WindowHandler.Mapper.AppendToMapping(nameof(IWindow),
                                                                    (handler, view) =>
        {
#if WINDOWS
            var nativeWindow = handler.PlatformView;
            IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(nativeWindow);
            WindowId WindowId = Win32Interop.GetWindowIdFromWindow(windowHandle);
            AppWindow appWindow = AppWindow.GetFromWindowId(WindowId);
            var presenter = appWindow.Presenter as OverlappedPresenter;
            presenter.IsResizable = false;
#endif
        });
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何调整平面窗口的大小? - How can I make a flat window resizable? 如何为Windows 8.1应用程序设置最小高度? - How to set minimum height for a Windows 8.1 app? 如何在Silverlight OOB应用程序中设置最小宽度和高度? - How to set minimum width and height in a silverlight OOB application? .net maui 将图形视图的宽度和高度更改为 window 或屏幕的大小 - .net maui change graphics view width and height to size of window or screen 如何设置HtmlTableRow的高度,以使其生成但不显示? - How can I set the height of an HtmlTableRow so that it will be generated but not display? 我怎样才能使我的 class 变量只能设置为三个选项之一? - How can I make it so my class variables can only be set to one of three choices? 我无法将 a.svg 文件设置为 maui 应用程序图标 - I can't set a .svg file as a maui app icon 我怎样才能让我的项目占用一列,以便我可以使用它插入另一个 window 的值和 select 来自 - How can i make my project take one column so i can use it in the insert into values from the other window with select from 如何做到这一点,使我的字段只设置一​​次? - How can I make it so my field is only set the one time? 如何使用Window.Eval将窗口的高度和宽度转换为C#? - How can I use Window.Eval to get height and width of window into c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM