简体   繁体   中英

The type 'NavigationWindow' does not support direct content

I am trying to use NavigationWindow class instead of Window to allow navigation between windows in WPF application. But when adding content to the NavigationWindow in XAML, I am getting an error: "The type 'NavigationWindow' does not support direct content". How can I overcome this problem?

You can't add any content to a NavigationWindow. It is just a "Window" where the Page is going to run, so you have to tell the NavigationWindow wich Page it is going to initial run, you do that by using "Source" Like this:

<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>

See a tutorial here: http://windowsclient.net/learn/video.aspx?v=4190

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM