WPF与传统的windows页面程序类似,但也有一些区别:
启动页:
方法一:
在文件中修改StartupUri的值。
方法二:在 后台代码中声明Main()方法、
[STAThread]
static void Main()
{
Window2 win = new Window2();
Application app = new Application();
(win);
}
方法三:
[STAThread]
static void Main()
{
Window2 win = new Window2();
Application app = new Application();
= win; ();
();
}
方法四:
[STAThread]
static void Main()
{
Application app = new Application();
= new Uri("", );
();
}
在窗体中:
<Window x:Class="Demo_1.Window1"
xmlns="/winfx/2006/xaml/presentation"
xmlns:x="/winfx/2006/xaml"
Title="Window with button" Height="300" Width="300">
<Button Name="button" Click="button_Click">click me</Button>
</Window>
其中:x:Class="Demo_1.Window1"指明了要与后台代码相关联的类,button的事件用特性语法注明了单击事件。