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

  • SEARCH
  • Home
  • 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 9194811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:30:01+00:00 2026-06-17T21:30:01+00:00

How do you navigate to a page from code that is inside of a

  • 0

How do you navigate to a page from code that is inside of a custom class. For example, lets say I have this code in my MainPage.xaml.cs:

private void DoSomething(object sender, RoutedEventArgs e)
{
   var work = new Work();
   work.doMore();
}

and in this class here is where I would like the navigation to actually take place:

public class Work
{
   public void DoMore()
   {
      // this is what I've tried, but doesn't work
      var myFrame = new Frame();
      myFrame.Navigate(typeof(HomePage));
   }
}
  • 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-06-17T21:30:03+00:00Added an answer on June 17, 2026 at 9:30 pm

    The code you tried doesn’t work because is not the main frame, you should publish the MainFrame reference to the rest of your code so that you can navigate outside views code behind.
    If you are making something simple I recommend putting a static property on the App class publishing the main frame instance.

    EDIT: Some code

    On App.xaml.cs
          public static Frame MainFrame{get;private set;}
    
          protected override void OnLaunched(LaunchActivatedEventArgs args)
                {
                    Frame rootFrame = Window.Current.Content as Frame;
                    MainFrame = rootFrame;
    (....)
                }
    Usage:
           App.MainFrame.Navigate(...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Page in Silverlight which is Navigated from the MainPage.xaml, called OpenPage.xaml,
I Have 2 page and the code to navigate to other page: NavigationService.Navigate(new Uri(/Page2.xaml,
I'm using webBrowser.Navigate(url) control to display page. I noticed this action steals focus from
I have code working to pass users from page to page within a Windows
I want to make a link from this page navigate to a details page
I want to navigate from code to some place with slide:right transition for example.
I have a page that displays data which is read from a cookie. The
I am using jquery mobile. I would like to navigate from one page to
I am using AutoIT within Internet Explorer to navigate from one web page to
I have a Internet explorer navigate to a page and I am able to

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.