5.2 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T02:57:35.324519+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 2e2061c5c6af1d0a |
Themes
Documentation: DTS.Common.CommonStyles
1. Purpose
This module defines a WPF ResourceDictionary subclass (CommonStyles) that encapsulates shared UI styles and event handlers for tooltips across the application. It is auto-generated from Themes/CommonStyles.xaml during the build process and serves as the runtime entry point for loading those styles into the WPF resource system. Its primary role is to ensure consistent tooltip behavior—specifically, attaching a common ToolTipOpening event handler (ToolTipEventHandler) to multiple named styles defined in the XAML source—without requiring manual wiring in application code.
2. Public Interface
The class CommonStyles is a partial class inheriting from System.Windows.ResourceDictionary and implementing IComponentConnector and IStyleConnector. It exposes only one public method:
void InitializeComponent()
Initializes the component by loading the embedded XAML resource dictionary from/DTS.Common;component/themes/commonstyles.xaml. This method is idempotent: it checks_contentLoadedand returns early on subsequent calls. It must be called before the dictionary is used (typically invoked automatically by the WPF framework or in the constructor of a consuming class).
Note
: All other methods (
Connect(int, object)forIComponentConnectorandIStyleConnector) are explicit interface implementations and are not intended for direct public consumption. They are invoked internally by the WPF build/runtime infrastructure.
3. Invariants
_contentLoadedisfalseinitially and set totrueon first call toInitializeComponent()orIComponentConnector.Connect(). Oncetrue, it is never reset.InitializeComponent()must be called exactly once per instance before the dictionary is used; otherwise, styles may not be loaded.- The
IStyleConnector.Connect()implementation assumes exactly 12 styles (connection IDs 1–12) inCommonStyles.xamleach define aToolTipOpeningevent handler. If the XAML changes (e.g., adds/removes styles), the generated code and XAML must be regenerated together to maintain correctness. - All event setters attach to
FrameworkElement.ToolTipOpeningEventusing the same handler:this.ToolTipEventHandler. The handler itself is not defined in this file—its implementation resides in the other partial part ofCommonStyles(likely inCommonStyles.xaml.cs), which is not provided here.
4. Dependencies
-
Dependencies of this module:
System.Windows.Application.LoadComponent()— used to load the embedded XAML resource.System.Windows.ResourceDictionary— base type.System.Windows.Markup.IComponentConnector,IStyleConnector— required for WPF’s build-time code generation contract.System.Windows.Controls.ToolTipEventHandler— delegate type for tooltip events.System.Windows.EventSetter— used to attach event handlers to styles.Microsoft.Windows.Controls— likely indicates dependency on Microsoft’s WPF Toolkit or similar (e.g.,Microsoft.Windows.Controls.DataVisualizationorCharting).
-
Dependencies on this module:
- Any WPF application or library referencing
DTS.Commonthat uses styles defined inCommonStyles.xaml. - The
CommonStyles.xamlfile itself (source) — this generated code is tightly coupled to it. Changes to the XAML require regeneration.
- Any WPF application or library referencing
5. Gotchas
- Auto-generated code: This file is auto-generated by
PresentationBuildTasks(WPF build tasks). Manual edits will be overwritten on rebuild. Always modifyCommonStyles.xaml(and its code-behind, if any) instead. - Missing handler definition: The
ToolTipEventHandlermethod is referenced but not defined in this file. Its implementation is assumed to exist in the correspondingCommonStyles.xaml.cs(not provided), which must be present at runtime—otherwise, aMissingMethodExceptionwill occur. - Hardcoded connection IDs: The
IStyleConnector.Connect()switch statement uses numeric IDs (1–12) that correspond to style definitions inCommonStyles.xaml. If styles are reordered, added, or removed in the XAML without regenerating, the event handlers may be attached to the wrong styles or not at all. - No public style keys exposed: This module does not expose any public constants or properties for style keys (e.g.,
x:Key="MyStyle"). Consumers must know or inspect the XAML to reference styles. - No validation of
targettype: TheIStyleConnector.Connect()method caststargettoStylewithout checking—passing a non-Styleobject will cause a runtimeInvalidCastException.
None identified from source alone beyond the above.
Note: Since the actual CommonStyles.xaml and CommonStyles.xaml.cs files are not provided, details about the specific styles, their keys, or the logic inside ToolTipEventHandler are inferred only from the generated code’s structure and line references.