* Use WindowEx for App.MainWindow.

* Moved MainWindow property setters to the constructor.

* Removed background brushes for Mica.

* Fixed MainWindow static initialization issues.

Updated to WinUIEx 1.7.0 and minor formatting fixes in comments.

* Added global using statement so extension methods are available on MainWindow.
This commit is contained in:
Mike Battista 2022-07-06 12:57:20 -07:00 коммит произвёл GitHub
Родитель 6f9cd56da9
Коммит f20cd1eaed
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 35 добавлений и 8 удалений

Просмотреть файл

@ -219,6 +219,9 @@
<DependentUpon>source.extension.vsixmanifest</DependentUpon>
</Compile>
<Compile Include="TemplateStudioForWinUICsPackage.cs" />
<Content Include="Templates\Proj\Default\Param_ProjectName\Usings.cs">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Templates\Proj\Default\Param_ProjectName\Helpers\TitleBarHelper.cs">
<IncludeInVSIX>true</IncludeInVSIX>
</Content>

Просмотреть файл

@ -3,7 +3,7 @@ using Param_RootNamespace.ViewModels;
namespace Param_RootNamespace.Views;
// To learn more about WebView2, see https://docs.microsoft.com/microsoft-edge/webview2/
// To learn more about WebView2, see https://docs.microsoft.com/microsoft-edge/webview2/.
public sealed partial class Param_ItemNamePage : Page
{
public Param_ItemNameViewModel ViewModel

Просмотреть файл

@ -20,11 +20,10 @@
"ts.outputToParent": "true",
"ts.version": "1.0.0",
"ts.displayOrder": "0",
"ts.licenses": "[Microsoft.WindowsAppSDK](https://www.nuget.org/packages/Microsoft.WindowsAppSDK/1.1.2/License)"
"ts.licenses": "[Microsoft.WindowsAppSDK](https://www.nuget.org/packages/Microsoft.WindowsAppSDK/1.1.2/License)|[WinUIEx](https://licenses.nuget.org/Apache-2.0)"
},
"sourceName": "Param_ProjectName",
"preferNameDirectory": true,
"guids": [ "378ed3d7-d630-4039-8b8e-93310ba6b05e" ],
"PrimaryOutputs": [
{ "path": "Param_ProjectName/Param_ProjectName.csproj" },
{ "path": "Param_ProjectName.Core/Param_ProjectName.Core.csproj" }
@ -93,6 +92,17 @@
},
"continueOnError": true
},
{
"description": "Add nuget package",
"manualInstructions": [],
"actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD",
"args": {
"packageId": "WinUIEx",
"version": "1.7.0",
"projectPath": "Param_ProjectName\\Param_ProjectName.csproj"
},
"continueOnError": true
},
{
"description": "Add nuget package",
"manualInstructions": [],

Просмотреть файл

@ -1,23 +1,37 @@
using Microsoft.UI.Xaml;
using Param_RootNamespace.Helpers;
// To learn more about WinUI3, see: https://docs.microsoft.com/windows/apps/winui/winui3/.
namespace Param_RootNamespace;
// To learn more about WinUI 3, see https://docs.microsoft.com/windows/apps/winui/winui3/.
public partial class App : Application
{
public static Window MainWindow { get; set; } = new Window() { Title = "AppDisplayName".GetLocalized() };
public static WindowEx MainWindow { get; } = InitializeMainWindow();
private static WindowEx InitializeMainWindow()
{
return new WindowEx()
{
Backdrop = new MicaSystemBackdrop(),
Content = null,
MinHeight = 500,
MinWidth = 500,
PersistenceId = "MainWindow",
Title = "AppDisplayName".GetLocalized()
};
}
public App()
{
InitializeComponent();
UnhandledException += App_UnhandledException;
}
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
{
// TODO: Log and handle exceptions as appropriate.
// For more details, see https://docs.microsoft.com/windows/winui/api/microsoft.ui.xaml.unhandledexceptioneventargs.
// https://docs.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.unhandledexception.
}
protected async override void OnLaunched(LaunchActivatedEventArgs args)

Просмотреть файл

@ -0,0 +1 @@
global using WinUIEx;

Просмотреть файл

@ -7,7 +7,6 @@
xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
Loaded="OnLoaded"
Unloaded="OnUnloaded"
Background="{ThemeResource SolidBackgroundFillColorBaseBrush}"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>

Просмотреть файл

@ -7,7 +7,6 @@
xmlns:helpers="using:Param_RootNamespace.Helpers"
xmlns:behaviors="using:Param_RootNamespace.Behaviors"
xmlns:i="using:Microsoft.Xaml.Interactivity"
Background="{ThemeResource SolidBackgroundFillColorBaseBrush}"
Loaded="OnLoaded">
<Grid>

Просмотреть файл

@ -59,6 +59,7 @@ public partial class App : Application
{
//^^
//{[{
await App.GetService<IActivationService>().ActivateAsync(args);
//}]}
}