大小差异:Powershell ISE vs Batch Launcher

时间:2017-07-05 18:05:43

标签: wpf windows powershell xaml

我有一个使用XML Node Reader在Powershell中创建的XAML GUI。当我在ISE中运行脚本时,我的所有控件都正是我想要的位置。然后我创建了一个批处理文件来启动它:

Powershell.exe -STA -File "C:\Scripts\Study App\Core.ps1"

运行批处理文件后,我注意到GUI本身比ISE中的大,因此,我的一些按钮未对齐。当我右键单击ps1文件并单击Run with Powershell时,我也注意到了这种行为。 ISE是什么导致窗口尺寸缩小,是否有办法解决这个问题?

问题here几乎完全相同但存在显着差异:我的表单类型为 System.Windows.Window ,并且没有所需的属性System.Windows.Forms.Form 有。

1 个答案:

答案 0 :(得分:1)

使用直接PowerShell时,PowerShell ISE会加载未加载的其他库。我做了一个快速搜索,并在另一个网站上发现了这个问题:

[https://social.msdn.microsoft.com/Forums/en-US/56352ca7-3e6e-452a-a1c8-09ab65c07089/powershell-wpf-window-sizes-different-when-run-outside-of-ps-ise?forum=wpf][1]

似乎解决方案可能正在使用SizeToContent =" WidthAndHeight"。

相关问题