avalonia-layout-zafiro
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAvalonia Layout with Zafiro.Avalonia
基于Zafiro.Avalonia的Avalonia布局
Master modern, clean, and maintainable Avalonia UI layouts. Focus on semantic containers, shared styles, and minimal XAML.
掌握现代、简洁且可维护的Avalonia UI布局。 重点关注语义化容器、共享样式和精简XAML。
🎯 Selective Reading Rule
🎯 选择性阅读规则
Read ONLY files relevant to the layout challenge!
仅阅读与布局挑战相关的文件!
📑 Content Map
📑 内容地图
| File | Description | When to Read |
|---|---|---|
| Theme organization and shared styles | Setting up or refining app themes |
| Semantic containers ( | Structuring views and layouts |
| Icon usage with | Adding and customizing icons |
| | Implementing complex interactions |
| Generic components and avoiding nesting | Creating reusable UI elements |
| 文件 | 描述 | 阅读时机 |
|---|---|---|
| 主题组织与共享样式 | 设置或优化应用主题时 |
| 语义化容器( | 构建视图与布局结构时 |
| 使用 | 添加或自定义图标时 |
| | 实现复杂交互时 |
| 通用组件与避免嵌套 | 创建可复用UI元素时 |
🔗 Related Project (Exemplary Implementation)
🔗 相关项目(示例实现)
For a real-world example, refer to the Angor project:
/mnt/fast/Repos/angor/src/Angor/Avalonia/Angor.Avalonia.sln如需真实世界示例,请参考Angor项目:
/mnt/fast/Repos/angor/src/Angor/Avalonia/Angor.Avalonia.sln✅ Checklist for Clean Layouts
✅ 简洁布局检查清单
- Used semantic containers? (e.g., instead of
HeaderedContainerwith manual header)Border - Avoided redundant properties? Use shared styles in files.
axaml - Minimized nesting? Flatten layouts using or generic components.
EdgePanel - Icons via extension? Use and
{Icon fa-name}for styling.IconOptions - Behaviors over code-behind? Use for UI-logic.
Interaction.Behaviors - Avoided Converters? Prefer ViewModel properties or Behaviors unless necessary.
- 是否使用了语义化容器?(例如,使用替代手动添加标题的
HeaderedContainer)Border - 是否避免了冗余属性? 在文件中使用共享样式。
axaml - 是否最小化了嵌套? 使用或通用组件扁平化布局。
EdgePanel - 是否通过扩展使用图标? 使用和
{Icon fa-name}进行样式设置。IconOptions - 是否优先使用Behaviors而非代码后置? 使用处理UI逻辑。
Interaction.Behaviors - 是否避免了转换器? 除非必要,否则优先使用ViewModel属性或Behaviors。
❌ Anti-Patterns
❌ 反模式
DON'T:
- Use hardcoded colors or sizes (literals) in views.
- Create deep nesting of and
Grid.StackPanel - Repeat visual properties across multiple elements (use Styles).
- Use for simple logic that belongs in the ViewModel.
IValueConverter
DO:
- Use for colors and brushes.
DynamicResource - Extract repeated layouts into generic components.
- Leverage specific panels like
Zafiro.Avaloniafor common UI patterns.EdgePanel
不要:
- 在视图中使用硬编码的颜色或尺寸(字面量)。
- 创建和
Grid的深层嵌套。StackPanel - 在多个元素中重复设置视觉属性(请使用样式)。
- 对属于ViewModel的简单逻辑使用。
IValueConverter
应该:
- 对颜色和画刷使用。
DynamicResource - 将重复的布局提取为通用组件。
- 利用特有的面板(如
Zafiro.Avalonia)实现常见UI模式。EdgePanel