Stylet.Avalonia 0.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Stylet.Avalonia --version 0.1.2                
NuGet\Install-Package Stylet.Avalonia -Version 0.1.2                
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="Stylet.Avalonia" Version="0.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Stylet.Avalonia --version 0.1.2                
#r "nuget: Stylet.Avalonia, 0.1.2"                
#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 Stylet.Avalonia as a Cake Addin
#addin nuget:?package=Stylet.Avalonia&version=0.1.2

// Install Stylet.Avalonia as a Cake Tool
#tool nuget:?package=Stylet.Avalonia&version=0.1.2                

Project Icon Stylet.Avalonia

英文文档

请注意本项目需要 AvaloniaUI 版本 >= 0.11.0-preview

项目介绍

Stylet.Avalonia是原来Stylet项目对AvaloniaUI 框架的适配。具体介绍请查看Stylet项目介绍

快速开始

第一步:创建一个AvaloniaUI框架

第二步:nuget 管理器安装 Stylet.Avalonia

第三步:创建AppBootstrapper类,其内容如下

public class AppBootstrapper:Bootstrapper<RootViewModel>
{
    
}

第四步:创建ShellViewModel类,以及Avalonia Window类型名为ShellView的窗口组件,其内容如下【其实啥也没动】

  • ShellViewModel.cs
public class ShellViewModel
{
    
}
  • ShellView.axaml
<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="Avalonia.NETCoreApp1.ShellView"
        Title="ShellView">
    Welcome to Avalonia!
</Window>
  • ShellView.axaml.cs
public partial class ShellView : Window
{
    public ShellView()
    {
        InitializeComponent();
#if DEBUG
        this.AttachDevTools();
#endif
    }

    private void InitializeComponent()
    {
        AvaloniaXamlLoader.Load(this);
    }
}

第五步:修改App.axaml文件,其内容如下:

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:s="using:Stylet.Xaml"
             xmlns:local="using:Avalonia.NETCoreApp1"
             x:Class="Avalonia.NETCoreApp1.App">
    <Application.Resources>
        <s:ApplicationLoader>
            <s:ApplicationLoader.Bootstrapper>
                <local:AppBootstrapper></local:AppBootstrapper>
            </s:ApplicationLoader.Bootstrapper>
        </s:ApplicationLoader>
    </Application.Resources>
    <Application.Styles>
        <FluentTheme Mode="Light"/>
    </Application.Styles>
</Application>

第六步:修改App.axaml.cs文件,其内容如下:

using Avalonia.Markup.Xaml;

namespace Avalonia.NETCoreApp1
{
    public partial class App : Application
    {
        public override void Initialize()
        {
            AvaloniaXamlLoader.Load(this);
        }
        
    }
}

第七步:运行。快乐的写代码吧!

其他

更多资料点击这里跳转查看。同时,可以查看本仓库中存放的示例项目。

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
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

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.1 119 9/23/2024
0.5.0 95 8/2/2024
0.4.2 157 2/5/2024
0.4.1 149 12/18/2023
0.4.0 160 12/7/2023
0.3.0 165 11/14/2023
0.2.0 221 8/3/2023
0.1.2 237 10/1/2022
0.1.1 208 10/1/2022
0.1.0 211 10/1/2022