WinUI3Utilities 1.1.7.9

dotnet add package WinUI3Utilities --version 1.1.7.9                
NuGet\Install-Package WinUI3Utilities -Version 1.1.7.9                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WinUI3Utilities" Version="1.1.7.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WinUI3Utilities --version 1.1.7.9                
#r "nuget: WinUI3Utilities, 1.1.7.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install WinUI3Utilities as a Cake Addin
#addin nuget:?package=WinUI3Utilities&version=1.1.7.9

// Install WinUI3Utilities as a Cake Tool
#tool nuget:?package=WinUI3Utilities&version=1.1.7.9                

WinUI3Utilities

Useful template methods for WinUI3 projects

Build

.NET Windows

Usage

The following is the general usage. For more details, see the XAML docs of the corresponding attributes.

Available APIs

Helpers
Helpers Usage
AppHelper Helper for Application
WindowHelper Get and set properties of Window
WindowSizeHelper Limit the size of the window (works with WindowSizeHelperAttribute)
DragMoveAndResizeHelper Apply drag-move and resize function to (UIElement)RootPanel
DragZoneHelper Reduce repetitive operations when using InputNonClientPointerSource
TitleBarHelper Set title bar
TeachingTipHelper Helper for TeachingTip
ContentDialogHelper Helper for ContentDialog
Misc Miscellaneous extension methods
ThrowHelper Throw helper
Attributes (Generators)
Attributes Usage
DependencyPropertyAttribute Generate a dependency property
LocalizedStringResourcesAttribute Generate for all the .resw and .resjson files in PRIResource under the specified namespace
$\dagger$ SettingsViewModelAttribute Generate property according to the properties of the settings class T for the specified viewmodel class
$\dagger$ GenerateConstructorAttribute Generate constructor like record for the specified type, according to the properties of it
$\dagger$ AppContextAttribute Generate field _containerConfiguration and methods Initialize/Load/SaveConfiguration for the specified class
WindowSizeHelperAttribute Generate helper properties to limit the window size (works with WindowSizeHelper)
AttributeIgnoreAttribute Ignores the effect of the specified attributes on this target
DisableSourceGeneratorAttribute Indicates that the source generator is disabled. This is usually used for debug purpose
  • $\dagger$: The attribute supports AttributeIgnoreAttribute

Settings Persistence

Only for packaged applications.

AppContext.cs:

using Microsoft.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.GetDefault().LocalFolder.Path;
        InitializeConfiguration();
        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 (Reference)

Generate for all the .resw and .resjson files in PRIResource 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="**\*.resw" />
        <PRIResource Include="**\*.resjson" />
    </ItemGroup>
    ...
</Project>

AssemblyInfo.cs:

[assembly: LocalizedStringResources(nameof(Sample))]

XXX\APage.resw: ...

XXX\BWindow.resjson: ...

NuGet GitHub

Contact Me

Poker

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net8.0-windows10.0.22621 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 202 9/20/2024
1.1.7.7 131 7/31/2024
1.1.7.6 935 6/14/2024
1.1.7.1 129 6/7/2024
1.1.6.3 146 3/30/2024
1.1.6.2 1,896 3/2/2024
1.1.6.1 1,703 2/13/2024
1.1.5.9 282 2/7/2024
1.1.5.8 606 1/22/2024
1.1.5.3 851 12/30/2023
1.1.5 157 12/29/2023
1.1.4.5 400 12/20/2023
1.1.4.3 2,232 7/4/2023
1.1.4 168 6/29/2023
1.1.3.2 208 6/18/2023
1.1.3 247 4/14/2023
1.1.2 196 4/12/2023
1.1.1.1 223 4/9/2023
1.1.1 223 4/8/2023
1.1.0 243 4/2/2023
1.0.13 311 3/11/2023
1.0.12.1 242 3/8/2023
1.0.12 253 3/7/2023
1.0.11.1 280 3/2/2023
1.0.11 286 3/1/2023
1.0.10 302 2/22/2023
1.0.9 478 1/23/2023
1.0.8 380 1/17/2023
1.0.7 341 1/16/2023
1.0.6 387 1/5/2023
1.0.5.1 358 1/4/2023
1.0.5 353 1/3/2023
1.0.4 387 1/1/2023
1.0.3 339 1/1/2023
1.0.2 330 12/31/2022
1.0.1 332 12/31/2022
1.0.0 337 12/31/2022