void SourceInitializedHandler(object sender, EventArgs e)
{
IntPtr handle = (new System.Windows.Interop.WindowInteropHelper(this)).Handle;
System.Windows.Interop.HwndSource hwndSource = System.Windows.Interop.HwndSource.FromHwnd(handle);
if (hwndSource != null)
hwndSource.AddHook(WindowProc);
}