对WinForm想必学员都已经很清楚,就是从System.Forms空间下的Application的静态方法Run传递一个Form类对象实例就OK了.关键代码如下:
System.Windows.Forms.Application.Run(new System.Windows.Forms.Form())
编译方法:
csc /t:winexe SimpleWinForm.cs
WPF窗体必须引用4个类库:PresentationCore, PresentationFramework, System, WindowsBase,然后会发现Forms命名空间下面多了Windows类,这就是WPF的窗体对象. 编译完成后可以用reflector对生成的执行文件反编译,参照reference就可以知道引用了那些dll库。
编译方法:
csc /t:winexe SimpleWPFWindow.cs /r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" /R:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" /R:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll"
WPF通过在System.Windows命名空间下面加新类Window和Application分别实现窗体和程序线程;
System.Windows.Window window = new Window();
System.Windows.Application application = new Application();
而Winform通过.net2.0提供的System.Windows.Forms命名空间下的Form类实现.
System.Windows.Forms.Application.Run(new System.Windows.Forms.Form());