1

我正在尝试使用 NavigationWindow 类而不是 Window 来允许在 WPF 应用程序中的窗口之间导航。但是在 XAML 中向 NavigationWindow 添加内容时,出现错误:“'NavigationWindow' 类型不支持直接内容”。我该如何克服这个问题?

4

1 回答 1

3

您不能向 NavigationWindow 添加任何内容。它只是页面将要运行的“窗口”,因此您必须告诉 NavigationWindow 至极页面它将初始运行,您可以使用“源”来执行此操作,如下所示:

<NavigationWindow x:Class="Tes.TesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Test" Height="300" Width="300" Source="Window1.xaml">
</NavigationWindow>

在此处查看教程:http: //windowsclient.net/learn/video.aspx?v=4190

于 2011-11-18T17:44:01.590 回答