Code Monkey home page Code Monkey logo

stylet.avalonia's Introduction

Project Icon Stylet.Avalonia

英文文档

请注意本项目需要 AvaloniaUI 版本 >= 11.x

项目介绍

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

快速开始

第一步:创建一个Avalonia框架类型的项目

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

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

  • 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();
    }
}

第四步:找到并打开App.axaml.cs文件,使其继承于StyletApplication<T>其中T为任一ViewModel,当前设置为第三步创建的ShellViewModel,修改后内容如下

public partial class App : StyletApplication<ShellViewModel>
{
    public override void Initialize()
    {
        AvaloniaXamlLoader.Load(this);
        base.Initialize(); // 初始化stylet,不能去掉
    }
}

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

其他

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

从 0.0.1升级?

请将avalonia 升级到11.x,升级指南

0.将nugetXamlNameReferenceGenerator移除(新版本已内置)

1.找到并打开App.axaml文件,移除AppBootstrapper资源,即:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <s:ApplicationLoader>
                <s:ApplicationLoader.Bootstrapper>
                    <local:AppBootstrapper  />
                </s:ApplicationLoader.Bootstrapper>
            </s:ApplicationLoader>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

2.找到并打开App.axaml.cs文件,使其继承于StyletApplication<T>, 此时App.axaml.cs成为了原来AppBootstrapper<ShellViewModel>, 将原来的AppBootstrapper.cs的内容移到App.axaml.cs文件中即可。

其注意App.axaml.cs文件内Initialize()方法必须调用base.Initialize();

stylet.avalonia's People

Contributors

sealoyal2018 avatar

Stargazers

Dong Bin avatar YangSpring avatar  avatar infinity1207 avatar 吴俊 avatar  avatar  avatar duyiduo avatar Stephen Monaco avatar  avatar  avatar 破晓 avatar

Watchers

 avatar  avatar

stylet.avalonia's Issues

avalonia版本更新

由于avalonia更新很快,我这边用了你的项目,自己做了avalonia版本对应,希望能更新到源码,你来做一下代码review,并帮忙发布到nuget。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.