C# SetWindowPlacement未设置Window.WindowsState

C# SetWindowPlacement未设置Window.WindowsState,c#,wpf,windowstate,C#,Wpf,Windowstate,在我们的公共项目中,应用程序主窗口(WPF窗口)的位置和大小是使用API的SetWindowPlacement方法设置的。WINDOWPLACEMENT的showCmd值为3。调用后,窗口实际上已最大化,右上角的图标显示正确的“至正常模式”图像,但Application.Current.MainWindow.WindowsState仍为“正常”。这会导致使用WindowsStartUpLocation=CenterOwner的非中心模式对话框。如果不另外将主窗口的WindowsState设置为M

在我们的公共项目中,应用程序主窗口(WPF窗口)的位置和大小是使用API的SetWindowPlacement方法设置的。WINDOWPLACEMENT的showCmd值为3。调用后,窗口实际上已最大化,右上角的图标显示正确的“至正常模式”图像,但Application.Current.MainWindow.WindowsState仍为“正常”。这会导致使用WindowsStartUpLocation=CenterOwner的非中心模式对话框。如果不另外将主窗口的WindowsState设置为Maximized,如何修复此问题?

我无法重现您的问题,我使用的是相同的API。什么时候调用
SetWindowPlacement
函数?代码是在重写OnSourceInitialized的窗口子类中执行的,直接在基本调用之后执行。我就是这样做的。您的目标.Net Framework版本是什么?