You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WinUI3中使用C++实现NavigationView页面导航的方法

WinUI3 + C++ 实现NavigationView页面导航问题

我正在使用C++开发一个WinUI3的NavigationView简单Demo,界面如下:
NavigationView Demo界面

遗憾的是目前没有相关资料或教程。

当前使用的XAML代码如下:

<Window
    x:Class="App1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <NavigationView x:Name="NavView"
                    IsTitleBarAutoPaddingEnabled="False"
                    IsTabStop="False" IsBackButtonVisible="Collapsed" PaneDisplayMode="Left">

        <NavigationView.MenuItems>
            <NavigationViewItem Icon="Page2" Content="Tab1" Tag="Tab1" IsSelected="True"/>
            <NavigationViewItem Icon="Page2" Content="Tab2" Tag="Tab2"/>
        </NavigationView.MenuItems>

        <ScrollViewer>
            <Frame x:Name="ContentFrame" Padding="12,0,12,24" IsTabStop="True"/>
        </ScrollViewer>

    </NavigationView>
</Window>

请问如何使用C++实现NavigationView的页面导航?以下代码中Navigate方法的参数应该如何填写:

ContentFrame().Navigate(**WHAT CODE GOES HERE**);

备注:我已掌握C#的实现方式,且不使用基于C++/WinRT的UWP方案,需要WinUI3+C++的解决方案。


内容的提问来源于stack exchange,提问作者Gaurang Dave

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 11:20:33