我正在学习 WPF,特别是 NavigationWindow。我想向窗口添加内容,例如状态栏、收藏夹栏等。 不幸的是,当我尝试添加任何内容时,出现错误。
我希望有一种方法可以在有人浏览页面时为页面添加书签;让用户将页面拖动到最喜欢的栏。
与状态栏类似的东西;我希望在状态栏上显示页面特定信息,而不必在每个单独的页面上显示它。
这可以通过导航窗口实现吗?还是我找错了树?
编辑:
<NavigationWindow x:Class="Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Nav Test" Height="300" Width="300" Source="Window1.xaml" >
<StatusBar></StatusBar> ' The type 'NavigationWindow' does not support direct content.
</NavigationWindow>
更新,我选择了什么:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Tracks" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="26" />
<RowDefinition Height="265*" />
</Grid.RowDefinitions>
<Menu Name="Menu1" />
<Frame Grid.Row="2" Name="Frame1" Source="PageSearchResults.xaml" />
<ToolBar Grid.Row="1" Name="ToolBar1" >
<Button Content="+" Name="Button1" />
</ToolBar>
</Grid>
</Window>
我最终将状态栏放在各个页面上,以便我可以更轻松地更改页面之间显示的内容,但工具栏与框架表现得很好。
最佳答案
如果您想要除页面之外的自己的内容,则不要使用 NavigationWindow。请改用常规窗口。然后,在您想要导航内容的位置添加 Frame 。 Frame 支持使用 NavigationWindow 可以执行的所有相同导航(事实上,NavigationWindow 基本上只是一个填充了 Frame 的窗口)。
关于具有更多控件的 WPF 导航窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5795140/