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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:30:44+00:00 2026-06-01T20:30:44+00:00

In my WPF app, I sometimes being up a System.Windows.MessageBox . When it is

  • 0

In my WPF app, I sometimes being up a System.Windows.MessageBox. When it is initially displayed, it is shown on top of my main application window, as I would like. Is there a way that I can force it to ALWAYS remain top of the main window? The problem I have is that when a MessageBox is displayed, users can then click on the main app window and bring it to the front, meaning the MessageBox becomes hidden from view. In this case the user might not realize it’s there, or forget about it, and to them, the main app seems to have frozen.

I’ve read a number of threads about this, but none have resolved the problem for me.

I ought to add that the thread putting up the MessageBox might not be the UI thread.
Thanks
Tom

  • 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-01T20:30:45+00:00Added an answer on June 1, 2026 at 8:30 pm

    Use the version of MessageBox.Show that takes a Window “owner” and pass your window.

    MessageBox.Show(Application.Current.MainWindow, "Im always on top - of the main window");
    

    If your possibly not on the UI thread try:

    string msg="Hello!";
    if (Application.Current.Dispatcher.CheckAccess()) {
        MessageBox.Show(Application.Current.MainWindow, msg);
    }
    else {
        Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(()=>{
            MessageBox.Show(Application.Current.MainWindow, msg);
        }));
    }
    

    You can:
    1. Invoke to block your thread until MessageBox is dismissed OR
    2. BeginInvoke in which case your thread code will continue to execute but UI thread will block on MessageBox until its dismissed).

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

Sidebar

Related Questions

I have a WPF App that implements a ListView. I would like to show
I am writing a ClickOnce WPF app that will sometimes be used over VPN.
I have a wpf application with a simple window that shows a text in
I'm creating a WPF app and have a system tray icon with a context
I have a WPF app that handles WM_GETMINMAXINFO in order to customize the Window
I have a WPF app which, when it starts, looks at the file system
In WPF App.Current.SessionEnding must return in a few seconds, otherwise the application does not
My application is a WPF App. I have decided to use ClickOnce to deploy
My wpf app is eating memory every time the ItemsSource of a TreeView is
I'm building a WPF app using pages and the navigation service. One of the

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.