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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:44:08+00:00 2026-05-22T18:44:08+00:00

I have made an application with a NavigationWindow with a page loaded in it.

  • 0

I have made an application with a NavigationWindow with a page loaded in it. Also is another (normal) window in this project.
The names of these windows/pages:

NavigationWindows: MainWindows
Page: Page1
Window: TwitterConnect
Label on Page: label4

I have a label on my Page1 and I want to change it from TwitterConnect.
Because I make a new instance of Page1 to call method ConnectToTwitter(), the label on my page doesn’t update.
Here is the code in de codebehind of TwitterConnect:

        private void button1_Click(object sender, RoutedEventArgs e)
        {  
            string pin = twitpin.Text;    

            Page1 page = new Page1();

            page.ConnectToTwitter(pin, genratedToken);

            this.Close();     
        }

I searched google to find a solution, but I don’t get it.
I think it has something to do with Dispatcher?!

I’m really a beginner in C#, VS10express and WPF.

How can I change label4 from TwitterConnect?
Can you please explain it with a snippet of code?

  • 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-22T18:44:08+00:00Added an answer on May 22, 2026 at 6:44 pm

    You are creating a new instance of Page1.xaml from the TwitterConnect window. What you need to do is find a way to access the current instance of Page1.xaml which can easily be acheived by using the DataContext property of the Window class.

    Page1.xaml.cs

    private void Page_Loaded(object sender, RoutedEventArgs e)
    {
        TwitterConnect twitterWindow = new TwitterConnect();
        // this gives TwitterConnect access to Page1's label4 property
        twitterWindow.DataContext = this;
        twitterWindow.Show();
    }
    

    TwitterConnect.xaml.cs

    private void ButtonClick(object sender, RoutedEventArgs e)
    {
        Page1 page1 = (Page1)this.DataContext;
    
        string pin = twitpin.Text;    
        page1.ConnectToTwitter(pin, genratedToken);
        // Then you can update the label like so:
        page1.Label4.Text = "The text you want to display on the label";
        this.Close();   
    }
    

    If I’ve missed anything out please let me know. Also, I strongly advise against this configuration as it could become a nightmare to maintain. A better approach might be to add a method or property onto Page1.cs to handle setting the text on label4.

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

Sidebar

Related Questions

I have made a web application that uses master page for Login & Logout
I have made an application project in Visual Studio 2008 C#, SQL Server from
I have made my application universal for iPhone and iPad (window-based application; universal) from
i have made an android application for Project Build Target as Target name:: Android
I have made an application for Windows & everytime I run the application by
I have made a application and the logo appears on every page. All 3
    I have made an application already that sends commands to an activated window. I
i have made an application where MainPage is the opening window of my application.
I have made an application which has tabs like in HelloTabActivity, there is also
I have made an mvc3 application with Windows Authentication. Everything works fine but I

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.