为什么 Application.Current
在 WinForms 应用程序中出现为空?应该如何以及何时设置?
我在做:
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.Run(new MainForm());
}
}
最佳答案
Application.Current 特定于 WPF 应用程序。 因此,当您在 WinForms 应用程序中使用 WPF 控件时,您需要初始化 WPF 应用程序的实例。在您的 WinForms 应用程序中执行此操作。
if ( null == System.Windows.Application.Current )
{
new System.Windows.Application();
}
关于c# - 为什么 Application.Current == null 在 WinForms 应用程序中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35902815/