73 lines
2.4 KiB
Markdown
73 lines
2.4 KiB
Markdown
---
|
||
applyTo: "**/*ViewModel.cs,**/*.xaml,MainShell/Converter/**/*.cs,MainShell/Home/**/*.cs,MainShell/ParaSetting/**/*.cs,MainShell/DeviceMaintance/**/*.cs,MainShell/PageCalib/**/*.cs,MainShell/Manual/**/*.cs"
|
||
---
|
||
|
||
# WPF and MVVM Instructions
|
||
|
||
## Framework
|
||
This repository uses WPF with Stylet.
|
||
|
||
## 中文说明
|
||
本项目 WPF 框架使用 Stylet,MVVM 相关代码必须遵循 Stylet 的约定。
|
||
|
||
## ViewModel Rules
|
||
- ViewModel classes should inherit from `Screen` or `PropertyChangedBase`
|
||
- Follow Stylet naming convention:
|
||
- XxxView ? XxxViewModel
|
||
- Do not introduce patterns that conflict with Stylet conventions
|
||
|
||
## 中文说明
|
||
ViewModel 规则:
|
||
- ViewModel 继承 `Screen` 或 `PropertyChangedBase`
|
||
- View 和 ViewModel 按命名约定自动绑定
|
||
- 不要引入与 Stylet 冲突的 MVVM 模式
|
||
|
||
## State Management
|
||
- Prefer bindable state objects to hold UI state
|
||
- Do not scatter many unrelated primitive bindable properties if a cohesive state model is more suitable
|
||
- Distinguish device input state and output state clearly
|
||
|
||
## 中文说明
|
||
状态管理建议:
|
||
- 优先使用可绑定状态对象统一承载界面状态
|
||
- 如果多个属性本质上属于一个状态域,不要分散定义在 ViewModel 中
|
||
- 输入状态和输出状态要明确分离
|
||
|
||
## IoC Rules
|
||
- IoC registrations belong in `StartBootstrapper.ConfigureIoC()`
|
||
- Singleton services should use `[Singleton]` or be registered as singleton in IoC
|
||
- New services must be registered consistently with existing project patterns
|
||
|
||
## 中文说明
|
||
IoC 规则:
|
||
- IoC 注册统一在 `StartBootstrapper.ConfigureIoC()` 中完成
|
||
- 单例服务通过 `[Singleton]` 或容器单例注册
|
||
- 新增服务必须遵循现有注册风格
|
||
|
||
## XAML Rules
|
||
- Do not manually implement `InitializeComponent`
|
||
- Do not work around WPF compilation issues by writing manual code-behind loaders
|
||
- Fix page compilation through project file and proper WPF item setup
|
||
- Value converters should be placed in `Converter/` and named `XxxConverter`
|
||
|
||
## 中文说明
|
||
XAML 规则:
|
||
- 不要手写 `InitializeComponent`
|
||
- 不要通过 code-behind 手工加载页面绕过编译问题
|
||
- 页面编译问题应通过 csproj 或 WPF 配置修复
|
||
- 转换器放在 `Converter/` 下,并使用 `XxxConverter` 命名
|
||
|
||
## Language Resource Rules
|
||
Project language resources are loaded from:
|
||
- `Language/MaxwellFramework_{lang}.xaml`
|
||
- `Language/MXJM_{lang}.xaml`
|
||
|
||
Keep generated UI code compatible with the existing localization mechanism.
|
||
|
||
## 中文说明
|
||
多语言资源加载遵循现有机制:
|
||
- 平台语言包:`MaxwellFramework_{lang}.xaml`
|
||
- 项目语言包:`MXJM_{lang}.xaml`
|
||
|
||
生成 UI 代码时不要破坏现有多语言机制。
|