我怎样才能设置一个Excel窗口的大小?

我有一个wpf窗口应该在Excel窗口旁边打开。 Excel打开并使用Interop.Excel进行处理。 在我的窗口中,我有一个方法,它应该设置Excel窗口的大小。

private void SetLayout() { Top = 0; Left = 0; Height = SystemParameters.WorkArea.Height; ((ConfiguratorWindowViewModel) DataContext).Manager.App.Height = SystemParameters.WorkArea.Height; ((ConfiguratorWindowViewModel) DataContext).Manager.App.Left = Width; ((ConfiguratorWindowViewModel) DataContext).Manager.App.Width = SystemParameters.WorkArea.Width - Width; } 

在我的ViewModel中,我有一个pipe理器,可以打开Excel应用程序(Office.Interop.Excel.Application)。 我可以设置我的wpf窗口的高度,顶部,它工作正常,但不是在Excel窗口。 我如何设置我的wpf窗口旁边的Excel窗口的大小,以便两个填充整个屏幕在一起?

编辑:

我试过这个,但它也不能正常工作:

 ((ConfiguratorWindowViewModel) DataContext).Manager.App.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlNormal; ((ConfiguratorWindowViewModel) DataContext).Manager.App.ActiveWindow.Height = Screen.PrimaryScreen.Bounds.Height; ((ConfiguratorWindowViewModel) DataContext).Manager.App.ActiveWindow.Width = Screen.PrimaryScreen.Bounds.Width - Width; 

两者都将高度设置为不同的值,但不是正确的,当我硬编码像.Height=800; 它也没有工作。

不幸的是,我不能发布图片来展示它的外观,它应该看起来像。

编辑:

问题是不一样的( 我怎么改变另一个程序的窗口的大小? )。 我不想改变啊“外国”应用程序的大小。

比方说,你有Excel应用程序存储在一个名为应用程序的variables。 那么你可以做这样的事情:

 App.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlNormal; App.ActiveWindow.Height = Screen.PrimaryScreen.Bounds.Height; App.ActiveWindow.Width = Screen.PrimaryScreen.Bounds.Width; 

屏幕类用于获得主屏幕的分辨率。

你可能也可以最大化窗口:

  App.WindowState = Microsoft.Office.Interop.Excel.XlWindowState.xlMaximized