Class WPFWindowWrapperHelper
- Namespace
- VisioForge.Core.UI.WPF
- Assembly
- VisioForge.Core.dll
Static helper class providing extension methods for seamless WinForms dialog integration in WPF applications.
This utility class extends WinForms Form objects with convenient extension methods that automatically handle the complexity of showing WinForms dialogs from WPF applications. It eliminates the need for manual window handle extraction and wrapper creation.
Key features:
- Extension methods for natural API usage
- Automatic window handle extraction and wrapper creation
- Proper parent-child relationship establishment
- Seamless integration between WPF and WinForms modal dialogs
- Clean, fluent API that hides interop complexity
Benefits:
- Simplified syntax for showing WinForms dialogs from WPF
- Automatic resource management for window handles
- Consistent modal dialog behavior across UI frameworks
- Reduced boilerplate code for mixed-mode applications
Thread safety: Extension methods should be called from the UI thread as they access WPF window handles.
public static class WPFWindowWrapperHelperInheritance
Inherited Members
Methods
ShowDialog(Form, Window)
Shows a WinForms dialog with proper parenting to a WPF window.
This extension method provides a convenient way to display WinForms dialogs from WPF applications while maintaining proper parent-child relationships. It automatically creates a WPFWindowWrapper to handle the Win32 interop and ensures the dialog appears modal to the parent WPF window.
The method handles:
- Automatic window handle extraction from the WPF parent
- Creation of the appropriate wrapper object
- Proper modal dialog behavior
- Correct Z-order and focus management
- Standard WinForms dialog result handling
Usage example: OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog(this) == DialogResult.OK) { ... }
Thread safety: Must be called from the UI thread.
public static DialogResult ShowDialog(this Form form, Window parent)Parameters
formForm-
The WinForms form/dialog to display.
parentWindow-
The parent WPF window that will own the dialog.
Returns
- DialogResult
-
The dialog result indicating how the dialog was closed.