具有更多控件的 WPF 导航窗口

发布于 2024-11-03 14:48:42 字数 1456 浏览 1 评论 0原文

我正在学习 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>

我最终将状态栏放在各个页面上,以便我可以更轻松地更改页面之间显示的内容,但工具栏与框架表现得很好。

I'm learning WPF, and NavigationWindow in particular. I want to add stuff to the window, like a status bar, a favorite bar, etc.
Unfortunately when I try adding anything, I get an error.

I'm hoping there might be a way that pages can be bookmarked as someone browses between them; let the user drag pages up to a favorite bar.

Something similar with the status bar; I'd like to have page specific information on the status bar, without having to have it on each individual page.

Is this possible with a navigation window, or am I barking up the wrong tree?

Edit:

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

Update, What I went with:

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

I ended up putting the status bar on the individual pages, so that I can more easily change what's displayed from page to page, but the tool bar behaves nicely with the frame.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

堇年纸鸢 2024-11-10 14:48:42

如果您想要除页面之外的自己的内容,则不要使用 NavigationWindow。请改用常规窗口。然后,在您想要导航内容的位置添加 框架。 Frame 支持与 NavigationWindow 相同的所有导航功能(事实上,NavigationWindow 基本上只是一个填充有 Frame 的窗口)。

If you want your own content apart from the Page, then don't use NavigationWindow. Use a regular Window instead. Then, in the place where you want your navigation content, add a Frame. Frame supports all the same navigation you can do with a NavigationWindow (in fact, a NavigationWindow is basically just a Window with a Frame filling it).

八巷 2024-11-10 14:48:42

我也是 WPF 新手,但我相信导航窗口需要一个起始“页面”,并且所有控件都应添加到该页面,而不是导航窗口本身。您可以向起始页添加一个框架,并从该框架导航到其他页面,而起始页可以包含您最喜欢的栏、状态栏等。

I'm new to WPF too but I believe a NavigationWindow needs a starting "Page" and that all your controls should be added to that page, not the NavigationWindow it's self. You could add a frame to the start page and do your navigations to other pages from that frame while the start page could contain your favorite bar, status bar etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文