avalonia-viewmodels-zafiro

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Avalonia ViewModels with Zafiro

Avalonia ViewModels 结合 Zafiro 使用

This skill provides a set of best practices and patterns for creating ViewModels, Wizards, and managing navigation in Avalonia applications, leveraging the power of ReactiveUI and the Zafiro toolkit.
本技能提供了一套在Avalonia应用中创建ViewModels、向导以及管理导航的最佳实践与模式,充分利用ReactiveUIZafiro工具包的强大功能。

Core Principles

核心原则

  1. Functional-Reactive Approach: Use ReactiveUI (
    ReactiveObject
    ,
    WhenAnyValue
    , etc.) to handle state and logic.
  2. Enhanced Commands: Utilize
    IEnhancedCommand
    for better command management, including progress reporting and name/text attributes.
  3. Wizard Pattern: Implement complex flows using
    SlimWizard
    and
    WizardBuilder
    for a declarative and maintainable approach.
  4. Automatic Section Discovery: Use the
    [Section]
    attribute to register and discover UI sections automatically.
  5. Clean Composition: map ViewModels to Views using
    DataTypeViewLocator
    and manage dependencies in the
    CompositionRoot
    .
  1. 函数式响应式方法:使用ReactiveUI(
    ReactiveObject
    WhenAnyValue
    等)处理状态与逻辑。
  2. 增强型命令:利用
    IEnhancedCommand
    实现更优的命令管理,包括进度报告和名称/文本属性。
  3. 向导模式:通过
    SlimWizard
    WizardBuilder
    实现复杂流程,采用声明式且易于维护的方式。
  4. 自动区域发现:使用
    [Section]
    特性自动注册和发现UI区域。
  5. 清晰的组合:通过
    DataTypeViewLocator
    将ViewModels映射到Views,并在
    CompositionRoot
    中管理依赖项。

Guides

指南

  • ViewModels & Commands: Creating robust ViewModels and handling commands.
  • Wizards & Flows: Building multi-step wizards with
    SlimWizard
    .
  • Navigation & Sections: Managing navigation and section-based UIs.
  • Composition & Mapping: Best practices for View-ViewModel wiring and DI.
  • ViewModels & 命令:创建健壮的ViewModels并处理命令。
  • 向导与流程:使用
    SlimWizard
    构建多步骤向导。
  • 导航与区域:管理导航和基于区域的UI。
  • 组合与映射:View-ViewModel关联与依赖注入的最佳实践。

Example Reference

示例参考

For real-world implementations, refer to the Angor project:
  • CreateProjectFlowV2.cs
    : Excellent example of complex Wizard building.
  • HomeViewModel.cs
    : Simple section ViewModel using functional-reactive commands.
如需真实场景的实现示例,请参考Angor项目:
  • CreateProjectFlowV2.cs
    :复杂向导构建的优秀示例。
  • HomeViewModel.cs
    :使用函数式响应式命令的简单区域ViewModel示例。