窗口具有标题栏(包括最小/最大/关闭按钮等),可用于承载 XAML 元素,例如用户控件。
您当然不限于每个应用程序使用一个窗口,但某些应用程序会选择该模式(一个窗口,托管各种用户控件)。
当您创建一个新的 WPF 应用程序时,默认情况下您的应用程序配置如下(在 App.xaml 中):
<Application x:Class="WpfApplication1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
StartupUri 属性告诉应用程序首先打开哪个窗口(您可以根据需要进行配置)
如果您想在逻辑上将 Window 分成几部分,并且不想在一个文件中包含太多 XAML,您可以执行以下操作:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>
<local:HeaderUserControl Grid.Row="0" />
<local:MainSectionUserControl Grid.Row="1" />
</Grid>
</Window>
其中HeaderUserControl 和MainSectionUserControl 是根据需要封装该窗口各个方面的用户控件。
如果您想显示另一个窗口,您可以在代码中调用Show 或ShowDialog 对您要显示的新窗口的实例...
另外 - 是的,页面是 WPF 浏览器应用程序的一部分,旨在在 Internet Explorer 中查看。