need help navigating

Eduardo Gomez 3,651 Reputation points
2025-04-22T15:43:27.52+00:00

I have

    <Grid x:Name="rootGrid">
        <NavigationView PaneDisplayMode="Left">
            <Interactivity:EventTriggerBehavior EventName="ItemInvoked">
                <Interactivity:InvokeCommandAction Command="{x:Bind MainWindowModel.NavigateCommand}" />
            </Interactivity:EventTriggerBehavior>
            <NavigationView.MenuItems>
                <NavigationViewItem
                    Tag="CalendarPage"
                    Content="Calendar"
                    Icon="Calendar" />
                <NavigationViewItem
                    Content="Account"
                    Tag="AccountPage"
                    Icon="Contact" />
                <NavigationViewItem
                    Tag="AboutPage"
                    Content="About"
                    Icon="Help" />
            </NavigationView.MenuItems>
        </NavigationView>

        <ContentControl
            Grid.Row="1"
            Content="{Binding CurrentPage}" />

    </Grid>
</winex:WindowEx>


and in the VM

using CommunityToolkit.Mvvm.Input;

namespace HorizonHub.ViewModel {
    public partial class MainWindowViewModel : ObservableObject {

        [ObservableProperty]
        object currentPage;

        public MainWindowViewModel() {

            CurrentPage = new CalendarPage();
        }

        [RelayCommand]
        void Navigate() {


        }
    }
}

code behind

    public MainWindowViewModel MainWindowModel { get; set; }

    public MainWindow(MainWindowViewModel mainViewModlel) {
        InitializeComponent();

        MainWindowModel = mainViewModlel;

        rootGrid.DataContext = MainWindowModel;

but for some reason, it doesn't trigger anything.

I need the tags, in order to go to the appropriate page

and when I put a breakpoint inn then navigate, it doesn't hit

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
878 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.