Size of MessageBox

Viewed 15091

How does .NET's MessageBox determine its size relative to the resolution of the screen on which it is displayed?

I am writing a slightly more flexible dialog window for a WPF application. The layout of the window is layed out in a Grid:

+-----------------
| auto: Header      // A header for the dialog.
+-----------------
| auto: Content     // can be any FrameworkElement.
+-----------------
| auto: BottomPanel // With buttons <OK>, <Cancel>, <Delete>, etc. 
+-----------------

The Contentcell can be VERY large. In one of my use cases, the user wants to delete x elements from a list. The elements are then listed in the confirmation dialog. If there are many (let's say 50+) elements, the window can get large—too large for my taste.

What I would like is a function that determines the MaxHeightand MaxWidthproperties of the dialog window from the current screen in a way that mimics Microsoft's own MessageBoxdialog.

PS: I invoke the message dialog with the following static method:

// MessageDialog class
public static object Show(
        Window owner, 
        FrameworkElement content,
        string title,
        string header,
        params MessageDialogButton[] buttons
        );
/* The MessageDialogButton class has the following properties: 
 * Text, ReturnValue, IsDefault, IsCancel. The class produces 
 * System.Windows.Controls.Button objects that when clicked 
 * return the value of their ReturnValue property--which is then
 * returned by MessageDialog::Show(...)
 */

PPS: To determine the screen on which to display the dialog, the screen on which the MessageDialog window's Owner is located. As a fallback, the first (primary) screen is used.

1 Answers
Related