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 6181099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:57:40+00:00 2026-05-24T00:57:40+00:00

I know the title isn’t very clear, I’ll try to explain myself better. I’ve

  • 0

I know the title isn’t very clear, I’ll try to explain myself better.

I’ve got in my MainPage.xaml a Listbox that I want to populate in a certain way. On that purpose, I have a Home.cs file with no xaml attached, whose constructor is like this:

public Home(string sid, ListBox lb){...}

In this constructor I do several POST requests with Webclient and, in the UploadStringCompleted method, I create several elements, stackpanels, textblocks and a hyperlinkbutton.

StackPanel bigPanel = new StackPanel();
bigPanel.Width = 456;

HyperlinkButton hyperlink = new HyperlinkButton();
hyperlink.Content = friend.name + " " + person.surname;
hyperlink.Click += new RoutedEventHandler(hyperlink_Click);
bigPanel.Children.Add(hyperlink);

lb.Items.Add(bigPanel);

And here comes the problem. I want this hyperlink to navigate to another page (FriendPage.xaml), but I can’t achieve it, because if I try to add NavigationService.Navigate(new Uri(“/FriendPage.xaml”, Urikind.Relative)) then it fails, it says “An object reference is required for the non-static method Navigate”.

As far as I know, this code line should be in MainPage.xaml, so, is there a way to do this? Or to place the hyperlink.Click event handler in MainPage.xaml.cs and bind it to a hyperlinkbutton that does not exist yet?

Thank you

  • 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-24T00:57:41+00:00Added an answer on May 24, 2026 at 12:57 am

    You can’t use the function NavigationService.Navigate because NavigationService is a class here, not an object. I think you have to add NavigationService to the parameters in your constructor for home, which you can use then. Like this:

    public void nav(NavigationService ANavigationService)
    {
       ANavigationService.Navigate(new Uri(""));
    }
    

    MainPage should have an instance of NavigationService, which you can pass to Home

    Edit:
    You can get the an instance of the navigationservice in MainPage with this:

    //in mainpage
    NavigationService navService = NavigationService.GetNavigationService(this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know the question title isn't the best. Let me explain. I do a
From the title I've put the question can seem very obvious... but it isn't
[Note: Title and text were heavily edited to make it more clear that I'm
::GetSystemMetrics (SM_CYBORDER) ...comes back with 1 and I know the title bar is taller
I know at first glance (due to the title) this looks like one of
I'd like to know how to grab the Window title of the current active
Feel free to edit the title if you know how to formulate the question
The title is kind of obscure. What I want to know is if this
As in a title, does anyone know how to freeze GridView header in ASP.NET
Excuse my title if it's confusing, but I don't know how else to describe

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.