WinUI3Utilities 1.1.3.2
See the version list below for details.
dotnet add package WinUI3Utilities --version 1.1.3.2
NuGet\Install-Package WinUI3Utilities -Version 1.1.3.2
<PackageReference Include="WinUI3Utilities" Version="1.1.3.2" />
paket add WinUI3Utilities --version 1.1.3.2
#r "nuget: WinUI3Utilities, 1.1.3.2"
// Install WinUI3Utilities as a Cake Addin #addin nuget:?package=WinUI3Utilities&version=1.1.3.2 // Install WinUI3Utilities as a Cake Tool #tool nuget:?package=WinUI3Utilities&version=1.1.3.2
WinUI3Utilities
Useful template methods for WinUI3 projects
Build
Usage
The following is the general usage. For more details, see the XAML docs of the corresponding attributes.
Initialize the CurrentContext
It is recommended to assign the CurrentContext.Window
in the first line of the MainWindow
's constructor,
because it is possible that other methods in the program will call CurrentContext.Window
before the end of the constructor.
This will avoid unassigned exceptions.
App.xaml.cs:
using Microsoft.UI.Xaml;
using WinUI3Utilities;
namespace Sample;
public partial class App : Application
{
public App()
{
InitializeComponent();
CurrentContext.Title = nameof(Sample);
}
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
_ = new MainWindow();
AppHelper.Initialize(new()
{
Size = WindowHelper.EstimatedWindowSize(),
...
});
}
}
MainWindow.xaml.cs:
using Microsoft.UI.Xaml;
using WinUI3Utilities;
namespace Sample;
public sealed partial class MainWindow : Window
{
public MainWindow()
{
CurrentContext.Window = this;
InitializeComponent();
}
}
Settings Persistence
Only for packaged applications.
AppContext.cs:
using Windows.Storage;
using WinUI3Utilities.Attributes;
namespace Sample;
[AppContext<AppConfig>]
public static partial class AppContext
{
public static string AppLocalFolder { get; private set; } = null!;
public static void Initialize()
{
AppLocalFolder = ApplicationData.Current.LocalFolder.Path;
InitializeConfigurationContainer();
AppConfig = LoadConfiguration() is not { } appConfigurations)
? new() : appConfigurations;
}
public static void SetDefaultAppConfig() => AppConfig = new();
public static AppConfig AppConfig { get; private set; } = null!;
}
AppConfig.cs:
using WinUI3Utilities.Attributes;
namespace Sample;
[GenerateConstructor]
public partial record AppConfig
{
public int WindowWidth { get; set; } = 1280;
public int WindowHeight { get; set; } = 720;
...
}
When saving configuration, you can use the following code:
AppContext.SaveConfiguration(AppContext.AppConfig)
Localization
Generate all the .resw files under the specified namespace.
Sample.csproj
<Project Sdk="Microsoft.NET.Sdk">
...
<PropertyGroup>
<EnableDefaultPriItems>false</EnableDefaultPriItems>
</PropertyGroup>
<Target Name="InjectAdditionalFiles" BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun">
<ItemGroup>
<AdditionalFiles Include="@(PRIResource)" SourceItemGroup="PRIResource" />
</ItemGroup>
</Target>
<ItemGroup>
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="SourceItemGroup" />
</ItemGroup>
...
<ItemGroup>
<PRIResource Include="XXX\APage.resw" />
<PRIResource Include="XXX\BWindow.resw" />
</ItemGroup>
...
</Project>
AssemblyInfo.cs:
[assembly: LocalizedStringResources(nameof(Sample))]
XXX\APage.resw: ...
XXX\BWindow.resw: ...
Project Link
Contact Me
License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0-windows10.0.19041 is compatible. net8.0-windows was computed. |
-
net7.0-windows10.0.19041
- Microsoft.Windows.SDK.BuildTools (>= 10.0.22621.756)
- Microsoft.WindowsAppSDK (>= 1.3.230602002)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on WinUI3Utilities:
Repository | Stars |
---|---|
Pixeval/Pixeval
Wow. Yet another Pixiv client!
|
Version | Downloads | Last updated |
---|---|---|
1.1.7.9 | 200 | 9/20/2024 |
1.1.7.7 | 129 | 7/31/2024 |
1.1.7.6 | 933 | 6/14/2024 |
1.1.7.1 | 127 | 6/7/2024 |
1.1.6.3 | 144 | 3/30/2024 |
1.1.6.2 | 1,894 | 3/2/2024 |
1.1.6.1 | 1,701 | 2/13/2024 |
1.1.5.9 | 280 | 2/7/2024 |
1.1.5.8 | 604 | 1/22/2024 |
1.1.5.3 | 849 | 12/30/2023 |
1.1.5 | 153 | 12/29/2023 |
1.1.4.5 | 398 | 12/20/2023 |
1.1.4.3 | 2,230 | 7/4/2023 |
1.1.4 | 166 | 6/29/2023 |
1.1.3.2 | 206 | 6/18/2023 |
1.1.3 | 245 | 4/14/2023 |
1.1.2 | 194 | 4/12/2023 |
1.1.1.1 | 221 | 4/9/2023 |
1.1.1 | 221 | 4/8/2023 |
1.1.0 | 241 | 4/2/2023 |
1.0.13 | 309 | 3/11/2023 |
1.0.12.1 | 240 | 3/8/2023 |
1.0.12 | 251 | 3/7/2023 |
1.0.11.1 | 278 | 3/2/2023 |
1.0.11 | 284 | 3/1/2023 |
1.0.10 | 300 | 2/22/2023 |
1.0.9 | 476 | 1/23/2023 |
1.0.8 | 378 | 1/17/2023 |
1.0.7 | 339 | 1/16/2023 |
1.0.6 | 385 | 1/5/2023 |
1.0.5.1 | 356 | 1/4/2023 |
1.0.5 | 351 | 1/3/2023 |
1.0.4 | 385 | 1/1/2023 |
1.0.3 | 335 | 1/1/2023 |
1.0.2 | 328 | 12/31/2022 |
1.0.1 | 330 | 12/31/2022 |
1.0.0 | 335 | 12/31/2022 |