如何将WPF窗口发送到后面?

在我的应用程序中,我有一个用于绘制调试数据的窗口。 当它加载时,我想在所有其他窗口后面“在后台”打开它。

实现这一目标的最佳方法是什么?

您可以使用以下代码:

[DllImport("user32.dll")] static extern bool SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); const UInt32 SWP_NOSIZE = 0x0001; const UInt32 SWP_NOMOVE = 0x0002; static readonly IntPtr HWND_BOTTOM = new IntPtr(1); static void SendWpfWindowBack(Window window) { var hWnd = new WindowInteropHelper(window).Handle; SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); } 

资料来源: http : //www.aeroxp.org/board/lofiversion/index.php?t4983.html

是否有任何特殊原因您不希望以最小化状态显示窗口并允许用户显示它? 如果以最小化状态显示窗口可以解决您的问题,请使用