Home > c#, WPF > How to make a Modal Dialog in WPF

How to make a Modal Dialog in WPF

The Scenario

I have created a c# WPF application. The app has an “About” page that I want to show as a modal dialog.

The Problem

The issue is when the “About” dialog is open and the user Alt+Tab’s the “About” dialog is visible as a separate tile in the Alt+Tab list. The about dialog also has a url link. Clicking this opens a browser window. When the user Alt+Tab’s back to the application the about dialog is visible whilst the calling app is now behind the web browser.


Firstly, in WPF create your dialog as a “Window” control.

In windows forms you would do:

  frmAbout about = new frmAbout();

In WPF its the same concept but syntactically slightly different:

  About aboutWindow = new About();
  aboutWindow.Owner = this;

This will open the window as a modal dialog.

One other setting to play with on the About window is WindowsStartUpLocation

  • CenterScreen
  • CenterOwner
  • Manual

Setting it as “CenterOwner” will open in the centre of the calling Window. I set mine to centre screen as it looked a bit funny starting centre of the owner.

VN:F [1.9.22_1171]
Rating: 4.2/10 (6 votes cast)
How to make a Modal Dialog in WPF, 4.2 out of 10 based on 6 ratings

Categories: c#, WPF Tags:
  1. No comments yet.
  1. No trackbacks yet.