Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:14:25+00:00 2026-05-25T10:14:25+00:00

I am new to WPF and i am using WPF Model-View-ViewModel Toolkit 0.1 to

  • 0

I am new to WPF and i am using WPF Model-View-ViewModel Toolkit 0.1 to get my hands on WPF.

I have a fairly simple question but i cant get my head around it.

How do i display new view from the menu item on the mainview?

This is how my code looks like:

MainView.xaml

<Menu DockPanel.Dock="Top">
   <MenuItem Header="_File">
      <MenuItem Command="{Binding NewPage}" Header="New Page" 
                                   InputGestureText="Ctrl-N" />
   </MenuItem>
</Menu>

MainViewModel.cs

private DelegateCommand newPageCommand;

    public ICommand NewPage
    {

        get
        {

            if (newPageCommand == null)
            {
                newPageCommand = new DelegateCommand(GoToNewPage);
            }
            return newPageCommand;
        }
    }


    private void GoToNewPage()
    {
      ???
    }

What do i write in the GoToNewPage to display the newPage.xaml?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:14:25+00:00Added an answer on May 25, 2026 at 10:14 am

    Usually your application is run entirely in the ViewModels, and Views are used to allow users to interact with the ViewModels in a friendly manner.

    In your case, the ViewModel might have a property called CurrentPage, which is bound to a ContentControl.Content in your View. To change pages, the GoToNewPage command would set the CurrentPage property to a NewPageViewModel.

    This would cause the ContentControl to realize it’s binding has changed, and in the process of updating the binding, it would realize that the Content has changed and it needs to use a new DataTemplate to draw that content.

    <ContentControl Content="{Binding CurrentPage}">
        <ContentControl.Resources>
            <DataTemplate DataType="{x:Type local:HomePageViewModel}">
                <local:HomePageView />
            </DataTemplate>
            <DataTemplate DataType="{x:Type local:NewPageViewModel}">
                <local:NewPageView />
            </DataTemplate>
        </ContentControl.Resources>
    </ContentControl>
    

    I have a simple example of this here if you’re interested

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using WPF with model-view-viewmodel pattern. I have a ResultsView and ResultsViewModel which
Simple WPF question I have a text Box and an OK Button and I
I have a WPF Window with a view model set as its DataContext, and
I'm pretty new to WPF and using the MVVM design pattern. To help learn
I'm using MVVM in a WPF app. I'm very new to both. Let me
New to wpf and through a learning curve. I have a userControl with a
I am fairly new to WPF and I am having a problem with inheriting
I am using MVVM Light toolkit in my WPF application. I would like to
I’m building a WPF application using MVVM pattern (both are new technologies for me).
I'm currently introducing Prism to a new Wpf application, and am using the MVVM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.