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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:25:23+00:00 2026-06-17T23:25:23+00:00

Possible Duplicate: Updating One Form After Event Occurs in Another Form Relevant info: Using

  • 0

Possible Duplicate:
Updating One Form After Event Occurs in Another Form

Relevant info: Using WPF Application, C#, Visual Studio 2010, .Net 4

I have two windows: Window1 and MainWindow. In Window1 I have a checkbox, that when checked, will set a label1 in MainWindow to not visible. How would I go about this?

I can’t do MainWindow newWindow = new MainWindow() because I’m not trying to make a new main window. I tried the following code but I get a exception thrown: {“Object reference not set to an instance of an object.”}`.

private void checkBox4_Checked(object sender, RoutedEventArgs e)
{
   if (checkBox4.IsChecked == true)
   {
       (Application.Current.MainWindow as MainWindow).label1.Visibility = 
                   Visibility.Hidden;
   }
   else
   {
       (Application.Current.MainWindow as MainWindow).label1.Visibility = 
                   Visibility.Visible;
   }
}

What would be the best way to go about this? Thanks in advanced.

  • 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-17T23:25:24+00:00Added an answer on June 17, 2026 at 11:25 pm

    Add an event to Window1:

    public event Action<bool> SomethingChecked; //TODO rename to indicate what was checked
    

    When the checkbox is checked raise that event:

    private void checkBox4_Checked(object sender, RoutedEventArgs e)
    {
        if(SomethingChecked != null)
            SomethingChecked(checkBox4.IsChecked);
    }
    

    Then add an event handler from the main form:

    Window1 other = new Window1();
    other.SomethingChecked += checked => label1.Visibility = 
        checked ? Visibility.Visible : Visibility.Hidden;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: NSLayoutConstraint crashes ViewController recently after updating Xcode my app now fails to
Possible Duplicate: Oracle: Updating a table column using ROWNUM in conjunction with ORDER BY
Possible Duplicate: Editing MySQL recode using a HTML form Like to know how to
Possible Duplicate: updating progress bar during a file search I'm using FindFirstFile and FindNextFile
Possible Duplicate: jQuery .data() Not Updating DOM I am having a problem with using
Possible Duplicate: Mercurial: copying ONE file and its history to another repository I have
Possible Duplicate: Not able to launch android emulator After downloading Eclipse indigo, and updating
Possible Duplicate: Android: trouble updating to Android SDK Tools, revision 7 I'm trying to
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: .NET progressbar not updating I built a progress bar class that shows

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.