nstyles 11.3.0.15

dotnet add package nstyles --version 11.3.0.15
                    
NuGet\Install-Package nstyles -Version 11.3.0.15
                    
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="nstyles" Version="11.3.0.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nstyles" Version="11.3.0.15" />
                    
Directory.Packages.props
<PackageReference Include="nstyles" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nstyles --version 11.3.0.15
                    
#r "nuget: nstyles, 11.3.0.15"
                    
#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.
#:package nstyles@11.3.0.15
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nstyles&version=11.3.0.15
                    
Install as a Cake Addin
#tool nuget:?package=nstyles&version=11.3.0.15
                    
Install as a Cake Tool

提供 Avalonia 的一些辅助类和扩展功能,及一套裁剪自 SukiUI 的主题。

BaseTemplateSelector

简化了模板选择器的实现。详细使用:

public class Person
{
    public string Name { get; set; } = string.Empty;
    public int Age { get; set; }
}

public class PersonTemplateSelector : BaseTemplateSelector
{
    protected override string? GetKey(object? data)
    {
        if (data == null) return "Person_PlaceHolder";
        var m = data as Person;
        if (m == null) return "Person_PlaceHolder";
        else return "Person_Normal";
    }
}

public partial class TemplateSelectorViewModel : ViewModelBase
{
    [ObservableProperty]
    private List<Person?> _users = new List<Person?>();
}
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="AvaloniaApp.TemplateSelectorWindow"
        xmlns:vm="clr-namespace:AvaloniaApp.ViewModels"
        x:DataType="vm:TemplateSelectorViewModel" Width="600" Height="400"
        Title="TemplateSelectorWindow">
  <ItemsControl VerticalAlignment="Center" ItemsSource="{Binding Users}">
    <ItemsControl.ItemsPanel>
      <ItemsPanelTemplate>
        <WrapPanel HorizontalAlignment="Center" ScrollViewer.VerticalScrollBarVisibility="Auto">
        </WrapPanel>
      </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
      <vm:PersonTemplateSelector>
        <DataTemplate x:Key="Person_PlaceHolder" x:DataType="vm:Person">
          <Border Background="LightGray" Padding="10" Margin="5" Width="100" Height="100" 
                  HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock Width="20" Height="20" LineHeight="20" FontSize="32" Text="+"></TextBlock>
          </Border>
        </DataTemplate>
        <DataTemplate x:Key="Person_Normal" x:DataType="vm:Person">
          <Border Background="LightGray" Padding="10" Margin="5" Width="100" Height="100">
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
              <TextBlock Text="{Binding Name}"></TextBlock>
            </StackPanel>
          </Border>
        </DataTemplate>
      </vm:PersonTemplateSelector>
    </ItemsControl.ItemTemplate>
  </ItemsControl>
</Window>
public partial class TemplateSelectorWindow : Window
{
    public TemplateSelectorWindow()
    {
        InitializeComponent();
        var vm = new ViewModels.TemplateSelectorViewModel();
        vm.Users.Add(null);
        vm.Users.Add(new ViewModels.Person() { Name = "张三", Age = 30 });
        vm.Users.Add(new ViewModels.Person() { Name = "李四", Age = 30 });
        this.DataContext = vm;
    }
}

NWindow

NWindow 精简了 Skui 的 SkuiWindow 实现,方便自定义带样式的窗口。使用时先添加主题:

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="AvaloniaApp.App"
             xmlns:ns="nstyles"
             RequestedThemeVariant="Default">
    <Application.Styles>
        <FluentTheme />
        
        <ns:NTheme />
    </Application.Styles>
</Application>
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on nstyles:

Package Downloads
newbeeui

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.3.0.15 151 5/29/2025
9.0.1.15 163 5/26/2025
9.0.1.14 145 5/26/2025
9.0.1.10 139 5/20/2025
9.0.1.4 164 4/20/2025
9.0.1.2 191 4/15/2025