--- source_files: - Common/DTS.Common/Base/View/BaseWindow.cs - Common/DTS.Common/Base/View/BaseView.cs generated_at: "2026-04-16T03:28:18.795367+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "5f5625420afe05bf" --- # View ## Documentation: `DTS.Common.Base` View Base Classes --- ### 1. Purpose This module provides foundational WPF view base classes (`BaseWindow` and `BaseView`) that standardize common UI behavior across the application. Specifically, they expose two key properties—`IsDirty` and `HeaderInfo`—by delegating to corresponding interfaces implemented by the `DataContext`. This enables consistent dirty-state tracking and tab header rendering across different view types (windows and user controls) without requiring each view to reimplement the logic. --- ### 2. Public Interface #### `BaseWindow` (inherits `System.Windows.Window`, implements `IBaseWindow`) - **`public bool IsDirty { get; }`** Returns `true` if the `DataContext` implements `IBaseWindowModel` *and* its `IsDirty` property is `true`; otherwise `false`. Returns `false` if `DataContext` is `null` or does not implement `IBaseWindowModel`. - **`public string HeaderInfo { get; }`** Returns the `HeaderInfo` string from the `DataContext` if it implements `IHeaderInfoProvider`; otherwise returns `string.Empty`. Returns `string.Empty` if `DataContext` is `null`. #### `BaseView` (inherits `System.Windows.Controls.UserControl`, implements `IBaseView`) - **`public bool IsDirty { get; }`** Returns `true` if the `DataContext` implements `IBaseViewModel` *and* its `IsDirty` property is `true`; otherwise `false`. Returns `false` if `DataContext` is `null` or does not implement `IBaseViewModel`. - **`public string HeaderInfo { get; }`** Returns the `HeaderInfo` string from the `DataContext` if it implements `IHeaderInfoProvider`; otherwise returns `string.Empty`. Returns `string.Empty` if `DataContext` is `null`. > **Note**: Both classes use *read-only* properties with no public setters. They are *passive aggregators*—they do not modify state or raise change notifications themselves. --- ### 3. Invariants - **`IsDirty` behavior**: - Always returns `false` if `DataContext` is `null`. - Always returns `false` if `DataContext` does not implement the *expected interface* (`IBaseWindowModel` for `BaseWindow`, `IBaseViewModel` for `BaseView`). - Otherwise, returns the exact value of `DataContext.IsDirty`. - **`HeaderInfo` behavior**: - Always returns `string.Empty` if `DataContext` is `null`. - Always returns `string.Empty` if `DataContext` does not implement `IHeaderInfoProvider`. - Otherwise, returns the exact value of `DataContext.HeaderInfo`. - **No side effects**: Neither property performs I/O, mutation, or triggers events. They are pure getters. --- ### 4. Dependencies #### Internal Dependencies (from source): - **`System.Windows`** (WPF core types: `Window`, `UserControl`) - **`DTS.Common.Base`** namespace (same assembly/module): - Interfaces: `IBaseWindow`, `IBaseView`, `IBaseWindowModel`, `IBaseViewModel`, `IHeaderInfoProvider` *(These interfaces are referenced but not defined in the provided source—must be defined elsewhere.)* #### External Dependencies: - **WPF runtime** (`PresentationFramework`, `WindowsBase`) - **ReSharper attributes** (`// ReSharper disable once CheckNamespace` suggests use of ReSharper for namespace conventions, but no runtime dependency) #### Inferred Consumers: - Any WPF view that inherits from `BaseWindow` or `BaseView`. - UI layers (e.g., `TabControl`) that bind to `HeaderInfo` and `IsDirty` on views. - ViewModels/Models implementing `IBaseWindowModel`, `IBaseViewModel`, or `IHeaderInfoProvider`. --- ### 5. Gotchas - **Interface mismatch risk**: `BaseWindow` expects `IBaseWindowModel` for `IsDirty`, while `BaseView` expects `IBaseViewModel`. Using the wrong model type (e.g., `IBaseViewModel` in a `BaseWindow`) will cause `IsDirty` to always return `false`, even if the model is dirty. - **No change notification**: These properties do *not* raise `INotifyPropertyChanged` events. If the underlying `IsDirty` or `HeaderInfo` values change, the view will *not* automatically update unless the `DataContext` itself raises property change notifications *and* the binding is set up to requery (e.g., via `BindingExpression.UpdateSource()` or `Mode=OneWay` with `INotifyPropertyChanged` on the *model*). - **`string.Empty` vs `null`**: `HeaderInfo` returns `string.Empty` (not `null`) when no provider is found—this avoids XAML binding errors but may require explicit handling if `null` is semantically meaningful. - **No validation or error handling**: If `DataContext.HeaderInfo` throws an exception, it will propagate unhandled. Similarly, if `DataContext` is a disposed or partially initialized object, behavior is undefined. - **Ambiguous naming**: The XML comments say "bound object data data" (double "data")—suggests legacy copy-paste or incomplete editing. Not a functional issue, but indicates possible tech debt. - **No explicit interface implementation**: Properties are *public* on the view classes, not explicit interface implementations. This may cause confusion if `IBaseWindow`/`IBaseView` are intended to be used as contracts. > **None identified from source alone** for additional gotchas beyond the above.