Код: Выделить всё
// this window size works with scaling 125% but not work with 150%
this.AppWindow.MoveAndResize(new Windows.Graphics.RectInt32(0, 0, 1200, 665));
< /code>
WelcomeScreen.xaml
Код: Выделить всё
< /code>
WelcomeScreen.xaml.cs
using Microsoft.UI.Windowing;
using Microsoft.UI;
using Microsoft.UI.Xaml;
using ViewModels.WelcomeScreen;
using System.ComponentModel;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace Views.WelcomeScreen
{
///
/// An empty window that can be used on its own or navigated to within a Frame.
///
public sealed partial class WelcomeScreen : Window
{
public WelcomeScreenPageViewModel WelcomeScreenPageViewModel { get; }
public void GetAppWindowAndPresenter()
{
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
WindowId myWndId = Win32Interop.GetWindowIdFromWindow(hWnd);
_apw = AppWindow.GetFromWindowId(myWndId);
_presenter = _apw.Presenter as OverlappedPresenter;
}
private AppWindow _apw;
private OverlappedPresenter _presenter;
private void InitializeControls()
{
GetAppWindowAndPresenter();
_presenter.IsResizable = false;
_presenter.IsMaximizable = false;
_presenter.IsMinimizable = false;
_apw.TitleBar.IconShowOptions = IconShowOptions.HideIconAndSystemMenu;
_apw.SetIcon("Assets/Apple.ico");
}
public WelcomeScreen(WelcomeScreenPageViewModel welcomeScreenPageViewModel)
{
this.InitializeComponent();
this.InitializeControls();
// this window size works with scaling 125% but not work with 150%
this.AppWindow.MoveAndResize(new Windows.Graphics.RectInt32(0, 0, 1200, 665));
WelcomeScreenPageViewModel = welcomeScreenPageViewModel;
UpdateNavigationFrame(0);
WelcomeScreenPageViewModel.PropertyChanged += ProcessPropertyChanged;
WelcomeScreenPageViewModel.ClosingRequest += (sender, e) => this.Close();
}
private void ProcessPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == (nameof(WelcomeScreenPageViewModel.CurrentPageIndex)))
UpdateNavigationFrame(WelcomeScreenPageViewModel.CurrentPageIndex);
}
private void UpdateNavigationFrame(int index)
{
WelcomeScreenPage1.Visibility = Visibility.Collapsed;
WelcomeScreenPage2.Visibility = Visibility.Collapsed;
WelcomeScreenPage3.Visibility = Visibility.Collapsed;
if (index == 0)
WelcomeScreenPage1.Visibility = Visibility.Visible;
if (index == 1)
WelcomeScreenPage2.Visibility = Visibility.Visible;
if (index == 2)
WelcomeScreenPage3.Visibility = Visibility.Visible;
}
}
}
< /code>
In resolution (1920*1080), Scale (125%):

In resolution (1920*1080), Scale (150%):

Scaling settings:

Подробнее здесь: https://stackoverflow.com/questions/794 ... in-winui-3