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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:35:29+00:00 2026-05-23T19:35:29+00:00

What I need is such an event handler in my window class. void someEventHandler(object

  • 0

What I need is such an event handler in my window class.

void someEventHandler(object sender, RoutedEventArgs e)
{
    MyNewWindow mnw = new MyNewWindow();
    mnw.Owner = Window.GetWindow(this);
    mnw.ShowDialog();
    this.Close();
}

Window.GetWindow(this) returns the parent window of the current window.

I had thought when the owner of the new window is the parent window of the current one, it would wait for the parent; and not the current one. But it did not work that way. Current window waits for the execution of the new and closes only after.

If I use Show() instead of ShowDialog() for some reason the window is not shown at all.

Probably I need some delegate methods but I am not sure where to start.

Edit: I guess I need to improve the question for future references:
The new window should be a dialog to the parent window. If I use Show() the parent window becomes accesible and I dont want that. If I use ShowDialog() it becomes a dialog to the current window, meaning that the current window does not close until the new window is closed, and I dont want that either.

  • 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-23T19:35:29+00:00Added an answer on May 23, 2026 at 7:35 pm

    Closing a window causes any windows that it owns to be closed.

    If you just want the owner window to not be visible, try this;

    void someEventHandler(object sender, RoutedEventArgs e)
    {
        MyNewWindow mnw = new MyNewWindow();
        mnw.Owner = this;
        this.Hide(); // not required if using the child events below
        mnw.ShowDialog();
    }
    

    You’ll likely want to hook up some event in the parent window that acts accordingly when you close the child window depending on your requirements.

    EDIT

    You could perhaps control the hiding of the (multiple parents) from the child;

    void OnLoad(object sender, RoutedEventArgs e)
    {
      this.Owner.Hide();
    }
    void Closed(object sender, RoutedEventArgs e)
    {
      this.Owner.Show();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to add an event listener/handler to a JavaScript object? Preferably
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
I need to display something such as below. Type A Type A Item 1
I need to access the OpenGL state variables (such as the MVP matrices) in
I need to compare 2 strings as equal such as these: Lubeck == Lübeck
I need to convert strings in Python to other types such as unsigned and
I need to convert unicode strings in Python to other types such as unsigned
We have a need to take dozens of different protocols from systems such as
Wnen I use external resources such as files or DB connection I need to
I need to test my PHP applications with multiple versions of PHP 5.x, such

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.