【问题标题】:The type 'NavigationWindow' does not support direct content“NavigationWindow”类型不支持直接内容
【发布时间】:2011-09-29 09:11:45
【问题描述】:
我正在尝试使用 NavigationWindow 类而不是 Window 来允许在 WPF 应用程序中的窗口之间导航。但是在 XAML 中向 NavigationWindow 添加内容时,出现错误:
“'NavigationWindow' 类型不支持直接内容”。我该如何克服这个问题?
【问题讨论】:
标签:
.net
wpf
navigation
window
navigationwindow
【解决方案1】:
您不能向 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