45 lines
2.0 KiB
Markdown
45 lines
2.0 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- Common/DTS.CommonCore/Base/ViewModel/ViewModelBase.cs
|
||
|
|
- Common/DTS.CommonCore/Base/ViewModel/BaseViewModel.cs
|
||
|
|
generated_at: "2026-04-17T15:40:45.497045+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "72dbfa917d46895e"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: DTS.Common.Base ViewModel Classes
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module provides two abstract base classes for the Model-View-ViewModel (MVVM) pattern within the DTS application framework. `ViewModelBase<T>` offers a foundational implementation for ViewModels that need property change notification, error handling, and asynchronous model initialization while inheriting from WPF's `DependencyObject`. `BaseViewModel<TModel>` provides a more feature-rich base class with Prism framework integration, including command management, region navigation, event aggregation, and dependency injection support. Both classes establish a consistent contract for ViewModel lifecycle management across the codebase.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### ViewModelBase\<T\>
|
||
|
|
|
||
|
|
**Type:** `abstract class`
|
||
|
|
**Inheritance:** `DependencyObject`, `INotifyPropertyChanged`, `IViewModel`
|
||
|
|
|
||
|
|
#### Properties
|
||
|
|
|
||
|
|
| Name | Type | Access | Description |
|
||
|
|
|------|------|--------|-------------|
|
||
|
|
| `Model` | `object` | get/set | The Model object instance. Note: typed as `object` despite generic parameter `T`. |
|
||
|
|
| `IsBusy` | `bool` | get/protected set | Indicates whether an asynchronous process is currently executing. |
|
||
|
|
| `IsDirty` | `bool` | get/protected set | Indicates whether the Model has been changed. Virtual. |
|
||
|
|
|
||
|
|
#### Events
|
||
|
|
|
||
|
|
| Name | Type | Description |
|
||
|
|
|------|------|-------------|
|
||
|
|
| `ErrorOccurred` | `EventHandler<ErrorEventArgs>` | Raised when an error occurs during processing. Virtual. |
|
||
|
|
| `PropertyChanged` | `PropertyChangedEventHandler` | Raised when a property value changes. Virtual. |
|
||
|
|
|
||
|
|
#### Abstract Methods (must be implemented by derived classes)
|
||
|
|
|
||
|
|
| Signature | Description |
|
||
|
|
|-----------|-------------|
|
||
|
|
| `protected abstract Task<T> InitializeAsync()` | Async initialization that returns the model object. Result is intended to set
|