Winform Boy in a WPF World - Window Handle
I was fiddling with some WPF stuff the other day and I needed the handle to the form. Windows in WPF do not have a property to get this like in WinForms, though there is a simple solution. I have bundled the solution into a property to make it similar to WinForms(It uses my lazy loader class):
public partial class HandleWindow : Window
{
public HandleWindow()
{
InitializeComponent();
_handle = new LazyLoader<IntPtr>(delegate { return new WindowInteropHelper(this).Handle; });
}
#region Handle
private LazyLoader<IntPtr> _handle;
protected IntPtr Handle
{
get
{
return _handle.Value;
}
}
#endregion
}