name: avalonia-ui-setup description: 使用跨平台XAML为Windows、macOS和Linux设置Avalonia UI项目 allowed-tools: Read, Write, Edit, Bash, Glob, Grep tags: [avalonia, dotnet, cross-platform, xaml, ui]
avalonia-ui-setup
使用跨平台XAML设置Avalonia UI项目,实现真正的跨平台桌面开发,一套代码库即可支持Windows、macOS和Linux。
功能
- 创建Avalonia项目结构
- 配置ReactiveUI的MVVM模式
- 设置平台特定功能
- 配置Fluent/Simple主题
- 设置原生菜单集成
- 为所有平台配置构建
- 设置热重载
- 生成平台特定的发布配置
输入模式
{
"type": "object",
"properties": {
"projectPath": { "type": "string" },
"projectName": { "type": "string" },
"theme": { "enum": ["fluent", "simple", "custom"] },
"mvvmFramework": { "enum": ["reactiveui", "community-toolkit", "custom"] }
},
"required": ["projectPath", "projectName"]
}
项目结构
MyAvaloniaApp/
├── App.axaml
├── MainWindow.axaml
├── ViewModels/
├── Views/
├── Models/
└── Program.cs
MainWindow.axaml
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="我的Avalonia应用">
<StackPanel>
<TextBlock Text="{Binding Greeting}"/>
<Button Command="{Binding ClickCommand}">点击我</Button>
</StackPanel>
</Window>
相关技能
wpf-xaml-style-generatorcross-platform-test-matrix