9.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T02:55:52.161759+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | af049870a2d42dd7 |
Dialogs Module Documentation
1. Purpose
This module provides infrastructure for displaying modal and non-modal dialog windows in a WPF application using Prism's interaction request pattern. It extends standard Prism Confirmation and Notification types with additional UI customization capabilities (e.g., button types, icons, window positioning) and provides dedicated window implementations (ConfirmationWindow, NotificationWindow) that suppress the standard close button via Win32 interop. The PopupWindowAction class acts as a behavior trigger that responds to interaction requests by creating and displaying popup windows, while BrowseForFolderDialog wraps the Win32 SHBrowseForFolder API for folder selection. The module supports region management and custom data context wiring through the IRegionManagerAware and IPopupWindowActionAware interfaces.
2. Public Interface
Interfaces
-
IRegionManagerAwarepublic interface IRegionManagerAware { IRegionManager RegionManager { get; set; } }Allows view models or views to receive a
RegionManagerinstance for region-based navigation within a popup window. -
IPopupWindowActionAwarepublic interface IPopupWindowActionAware { Window HostWindow { get; set; } Notification HostNotification { get; set; } }Enables views or view models to access the host window and the original
Notification/Confirmationcontext when displayed viaPopupWindowAction.
Classes
-
ConfirmationExpublic class ConfirmationEx : ConfirmationExtends Prism's
Confirmationwith additional properties:Buttons MessageBoxButton { get; set; } = MessageBoxButton.OKCancelImage MessageBoxImage { get; set; } = MessageBoxImage.QuestionResult MessageBoxResult { get; set; }
-
ConfirmationWindowpublic partial class ConfirmationWindowA window for displaying confirmation dialogs. Key members:
ConfirmationTemplate DataTemplate { get; set; }Connect(int connectionId, object target)— throwsNotImplementedException- Suppresses the close button via
GetWindowLong/SetWindowLongonSourceInitialized.
-
NotificationWindowpublic partial class NotificationWindow : WindowA window for displaying notification dialogs. Key members:
NotificationTemplate DataTemplate { get; set; }ImageUri Uri { get; set; }— defaults towarning_48.pngConnect(int connectionId, object target)— empty implementationCoppyToClibord_Click(...)— sets clipboard to"Hello, clipboard"- Suppresses the close button via
GetWindowLong/SetWindowLongonSourceInitialized.
-
PopupWindowActionpublic class PopupWindowAction : TriggerAction<FrameworkElement>A Prism behavior that displays popup windows in response to interaction requests. Key properties:
WindowContent FrameworkElement { get; set; }ContentTemplate DataTemplate { get; set; }IsModal bool { get; set; }StartupPosition WindowPositions { get; set; }— enum:CenterOwner,CenterScreenAllowMultipleNotificationWindows bool { get; set; }CenterOverAssociatedObject bool { get; set; }— commented out in current codeTimeoutInterval intandTimeoutResult ResultEnum— commented out
Key methods:
Invoke(object parameter)— handles interaction request, positions window, sets up callbacks, and shows window (modal/non-modal).PrepareContentForWindow(Notification notification, Window wrapperWindow)— injectsRegionManager, setsHostWindow/HostNotificationonIPopupWindowActionAwaretargets.GetWindow(Notification notification)— creates or reuses a window.CreateWindow(Notification notification)— instantiatesConfirmationWindoworNotificationWindowbased on type.GetImageUri(PopupWindowImage windowImage)— resolves image URIs (e.g.,error_48.png,warning_48.png).
-
BrowseForFolderDialogpublic class BrowseForFolderDialogWraps Win32
SHBrowseForFolderfor folder selection. Key properties:SelectedFolder string { get; protected set; }Title string { get; set; }InitialFolder string { get; set; }InitialExpandedFolder string { get; set; }OKButtonText string { get; set; }BrowseInfo BROWSEINFOW { get; protected set; }BrowserDialogFlags BrowseInfoFlags { get; set; }
Key methods:
ShowDialog()/ShowDialog(Window owner)— displays dialog and returnsNullable<bool>.BrowseEventHandler(...)— callback for dialog events (BFFM_INITIALIZED,BFFM_SELCHANGED, etc.).
Win32 interop:
SHBrowseForFolderW,SHGetPathFromIDList,SendMessageWBROWSEINFOW,BrowseInfoFlags,MessageFromBrowser,MessageToBrowserenums/structs.
3. Invariants
- Window Closing Behavior: Both
ConfirmationWindowandNotificationWindowunconditionally remove the system menu (and thus the close button) viaGetWindowLong/SetWindowLongduringSourceInitialized. This is non-negotiable and cannot be overridden. - RegionManager Injection:
PopupWindowAction.PrepareContentForWindowensures that ifWindowContent(or itsDataContext) does not already have aRegionManager, a new scopedRegionManageris created and assigned. This is always applied whenWindowContentis non-null. - IPopupWindowActionAware Wiring: If
WindowContentor itsDataContextimplementsIPopupWindowActionAware,HostWindowandHostNotificationare always set to the created window and notification context. - Window Content Ownership:
PopupWindowAction.Invokereturns early ifWindowContent.Parent != null, preventing reuse of content already in a visual tree. - Multiple Notifications: When
AllowMultipleNotificationWindowsisfalse, only oneNotificationWindowis retained in_openedNotificationWindow; subsequent notifications reuse this instance (though the code does not show explicit reuse logic beyond assignment). - BrowseForFolderDialog State:
InitialExpandedFolderoverridesInitialFolderwhen set duringBFFM_INITIALIZED.
4. Dependencies
External Dependencies
- Prism.Core (via
Prism.Regions,IRegionManager,InteractionRequestedEventArgs) - Microsoft.Xaml.Behaviors (via
TriggerAction<FrameworkElement>) - System.Windows (WPF types:
Window,DataTemplate,FrameworkElement,Uri,Clipboard) - Win32 APIs (via
user32.dll,shell32.dll):SetWindowLong,GetWindowLong,SHBrowseForFolderW,SHGetPathFromIDList,SendMessageW
Internal Dependencies
- DTS.Common.Interactivity (for
Notification,NotificationContentEventArgs,PopupWindowImage) - DTS.Common.Enums (for
PopupWindowImage) - DTS.Common.Events (referenced but no direct usage in these files)
Depended Upon By
- Likely used by UI layers (Views) via
PopupWindowActionbehaviors bound to interaction requests. BrowseForFolderDialogis likely consumed by view models or services requiring folder selection.
5. Gotchas
ConfirmationWindow.ConnectthrowsNotImplementedException: This method is present but non-functional; callers must avoid invoking it.NotificationWindow.CoppyToClibord_Clickis hardcoded: Sets clipboard to"Hello, clipboard"— likely a placeholder or debugging artifact.CenterOverAssociatedObjectis commented out: The legacy property is defined but unused; developers should useStartupPositioninstead.- Timeout behavior is commented out:
TimeoutIntervalandTimeoutResultproperties exist only in comments; no auto-cancellation is implemented. BrowseForFolderDialogrequiresOleInitialize()forBIF_NEWDIALOGSTYLE: The documentation comment forBIF_NEWDIALOGSTYLEnotes this requirement, but the class does not enforce or perform it.BrowseForFolderDialogusesSelectedFolderas both input and output:InitialFolderandInitialExpandedFolderset initial state, butSelectedFolderis updated duringBFFM_SELCHANGEDand returned as the final selection.PopupWindowAction.GetWindowcreates a newWindowwhenWindowContentis set: This may lead to unexpected window hierarchy ifWindowContentis reused elsewhere.- No validation of
PopupWindowImagevalues:GetImageUridefaults to"warning_48.png"for unknown values — no exception or warning is raised.