[英]Why do I have to use the Application class to use WPF windows?
I create my Window class 我创建我的Window类
class myWin : Window
{
public myWin()
{
Title = "My";
MaxWidth = 500;
MaxHeight = 500;
}
}
Why I can not run 'myWin' without run Application's instance? 为什么没有运行应用程序的实例就无法运行“ myWin”?
Runs, but with freeze (Do not work). 运行,但冻结 (不工作)。
myWin a = new myWin();
a.Show();
Works Perfectly! 完美的作品!
myWin a = new myWin();
a.Show();
Application b = new Application();
b.Run();
I am using Xamarin Studio 我正在使用Xamarin Studio
The reason is that the Application
class implements all the necessary plumbing/infrastructure to run a Windows application. 原因是
Application
类实现了运行Windows应用程序所需的所有必要的管道/基础结构。
The main part is the management of the message pump which processes all the messages sent by the OS to the application, particularly the repaint events which trigger the ... repaint of the rendering surface of the application. 主要部分是消息泵的管理,该消息泵处理OS发送给应用程序的所有消息,尤其是重绘事件,这些事件触发应用程序渲染表面的重绘。
So what the Application.Run
do is essentially starting the message pump . 因此,
Application.Run
所做的本质上是启动消息泵 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.