- fix for overriding mainpage
This commit is contained in:
Родитель
77a61acbf1
Коммит
b67249f955
|
@ -10,16 +10,10 @@ namespace Maui.Controls.Sample
|
|||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
SetMainPage(CreateDefaultMainPage());
|
||||
}
|
||||
|
||||
public static bool PreloadTestCasesIssuesList { get; set; } = true;
|
||||
|
||||
public void SetMainPage(Page rootPage)
|
||||
{
|
||||
MainPage = rootPage;
|
||||
}
|
||||
|
||||
public Page CreateDefaultMainPage()
|
||||
{
|
||||
return new CoreNavigationPage();
|
||||
|
@ -30,10 +24,10 @@ namespace Maui.Controls.Sample
|
|||
base.OnAppLinkRequestReceived(uri);
|
||||
}
|
||||
|
||||
#if WINDOWS || MACCATALYST
|
||||
protected override Window CreateWindow(IActivationState activationState)
|
||||
{
|
||||
var window = base.CreateWindow(activationState);
|
||||
var window = new Window(CreateDefaultMainPage());
|
||||
#if WINDOWS || MACCATALYST
|
||||
|
||||
// For desktop use a fixed window size, so that screenshots are deterministic,
|
||||
// matching (as much as possible) between dev machines and CI. Currently
|
||||
|
@ -65,9 +59,10 @@ namespace Maui.Controls.Sample
|
|||
window.MinimumHeight = desktopWindowHeight;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
return window;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using Maui.Controls.Sample.Issues;
|
||||
using Maui.Controls.Sample.Issues;
|
||||
|
||||
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
|
||||
|
@ -42,67 +42,4 @@ namespace Maui.Controls.Sample
|
|||
return appBuilder.Build();
|
||||
}
|
||||
}
|
||||
|
||||
class App : Application
|
||||
{
|
||||
public const string AppName = "CompatibilityGalleryControls";
|
||||
public const string DefaultMainPageId = "ControlGalleryMainPage";
|
||||
|
||||
public App()
|
||||
{
|
||||
}
|
||||
|
||||
public static bool PreloadTestCasesIssuesList { get; set; } = true;
|
||||
|
||||
public Page CreateDefaultMainPage()
|
||||
{
|
||||
return new CoreNavigationPage();
|
||||
}
|
||||
|
||||
protected override void OnAppLinkRequestReceived(Uri uri)
|
||||
{
|
||||
base.OnAppLinkRequestReceived(uri);
|
||||
}
|
||||
|
||||
protected override Window CreateWindow(IActivationState activationState)
|
||||
{
|
||||
var window = new Window(CreateDefaultMainPage());
|
||||
#if WINDOWS || MACCATALYST
|
||||
|
||||
// For desktop use a fixed window size, so that screenshots are deterministic,
|
||||
// matching (as much as possible) between dev machines and CI. Currently
|
||||
// our Windows CI machines run at 1024x768 resolution and the window size can't
|
||||
// be larger than screen size. We'll investigate increasing CI screen
|
||||
// resolution in the future so we can have a bigger window, but for now
|
||||
// this size works.
|
||||
const int desktopWindowWidth = 1024;
|
||||
const int desktopWindowHeight = 768;
|
||||
|
||||
#if WINDOWS
|
||||
window.Width = desktopWindowWidth;
|
||||
window.Height = desktopWindowHeight;
|
||||
|
||||
var info = Microsoft.Maui.Devices.DeviceDisplay.MainDisplayInfo;
|
||||
int screenWidth = (int)(info.Width / info.Density);
|
||||
int screenHeight = (int)(info.Height / info.Density);
|
||||
|
||||
// Center the window on the screen, to ensure no part of it goes off screen in CI
|
||||
window.X = (screenWidth - desktopWindowWidth) / 2;
|
||||
window.Y = (screenHeight - desktopWindowHeight) / 2;
|
||||
#elif MACCATALYST
|
||||
// Setting max and min is currently needed to force the size on Catalyst;
|
||||
// just setting width/height has no effect on Catalyst
|
||||
window.MaximumWidth = desktopWindowWidth;
|
||||
window.MinimumWidth = desktopWindowWidth;
|
||||
|
||||
window.MaximumHeight = desktopWindowHeight;
|
||||
window.MinimumHeight = desktopWindowHeight;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
return window;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче