
点击XAML试图按钮后,App.xaml页面对应的XAML代码如下
[tr][td]01 <Application x:Class="BrowserDemo.App"
02 XMLns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
03 XMLns:x="http://schemas.microsoft.com/winfx/2006/xaml"
04 StartupUri="Page1.xaml"
05 >
06 <Application.Resources>
07
08 </Application.Resources>
09 </Application>[/td][/tr]
在第1行代码处我们可以看到,在应用程序定义文件中我们使用了Application元素,并且用x:Class 属性指定了一个与之关联的C#不完全类(后一个程序清单的第14行代码所示),而后在程序编译时,会自动将应用程序定义文件和包含关联C#不完全类的代码后置文件这两部分结合在一起,从而创建一个完整的BrowserDemo命名空间下的App类,注意,BrowserDemo.App类是从WPF提供的System.Windows.Application类中派生的。第4行代码使用了StartupUri属性为该WPF程序指定首次运行程序时要加载的XAML页面文件。在一个Browser Application类型的WPF程序中,我们可以添加多个XAML页面,并支持在这些页面间进行跳转和切换。
提示:
而App.xaml.cs的代码如下(可以通过App.xaml页面的Source按钮切换到源码试图):
[tr][td]01 using System;
02 using System.Windows;
03 using System.Windows.Navigation;
04 using System.Data;
05 using System.Xml;
06 using System.Configuration;
07
08 namespace BrowserDemo
09 {
10 /// <summary>