本文介绍了使用windowHandle显示WPFHidden窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 WPF窗口代码 var windowInteropHelper = new WindowInteropHelper(this); int tempHandle =(int)windowInteropHelper.Handle; string filePath = @" C:\ windowHandleLog.txt" ;; if(File.Exists(filePath)) { File.Delete(filePath); } File.AppendAllText(filePath,tempHandle.ToString()); this.Hide(); 控制台应用程序代码: [DllImport(" User32")] private static extern int ShowWindow (int hwnd,int nCmdShow); string filePath = @" C:\ windowHandleLog.txt" ;; string handle = File.ReadAllText(filePath); int windowHandle = Convert.ToInt32(handle); ShowWindow(windowHandle,SW_SHOW); 我创建了一个WPF窗口并添加了一些控件。现在我将获得窗口句柄并隐藏窗口。 我将创建单独的应用程序(控制台)并使用 windowHandle 显示窗口。 但问题是窗口即将到来ith黑色背景。没有显示控件。 请参考上面的代码。 任何人都可以帮忙完成它(使用窗口句柄显示WPF窗口) WPF窗口: 窗口使用窗口句柄显示后 谢谢和问候, Ashish Agrawal 46 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id =" 146" id =" 146"> Thavote< / g> 解决方案 嗨agrawal.ashish, 关于你的问题,我不能给出一个解决方案,但我已经将你的问题上报了,请等一下。 Best问候, Cherry WPF window Codevar windowInteropHelper = new WindowInteropHelper(this);int tempHandle = (int)windowInteropHelper.Handle;string filePath = @"C:\windowHandleLog.txt";if (File.Exists(filePath)){ File.Delete(filePath);}File.AppendAllText(filePath, tempHandle.ToString());this.Hide();Console Application Code:[DllImport("User32")]private static extern int ShowWindow(int hwnd, int nCmdShow);string filePath = @"C:\windowHandleLog.txt";string handle = File.ReadAllText(filePath);int windowHandle = Convert.ToInt32(handle);ShowWindow(windowHandle, SW_SHOW);I have created one WPF window and added some control to it. Now I will get the window handle and hide the window.I'll create the separate application (console) and use the windowHandleshow the window.but the issue is the window is coming with the black background. Not showing the control.Please refer above code.Can anyone help how to get it done (Showing WPF window using window handle)WPF Window:window After showing from using window handleThanks & Regards,Ashish Agrawal46 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="146" id="146">Thavote</g> 解决方案 Hi agrawal.ashish,About your issue, and I can not give one solution, but I have escalated your issue for help, please wait a minute.Best Regards,Cherry 这篇关于使用windowHandle显示WPFHidden窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-03 14:19