Creating a dialog box
A dialog box is a Window
that is typically used to get some data from the user, before some operation can proceed. This is sometimes referred to as a modal window (as opposed to modeless, or non-modal). In this recipe, we'll take a look at how to create and manage such a dialog box.
Getting ready
Make sure Visual Studio is up and running.
How to do it...
We'll create a dialog box that's invoked from the main window to request some information from the user:
Create a new WPF application named
CH05.Dialogs
.Add a new
Window
namedDetailsDialog.xaml
(aDetailsDialog
class is created).Visual Studio opens
DetailsDialog.xaml
. Set someWindow
properties:FontSize
to16
,ResizeMode
toNoResize
,SizeToContent
toHeight
, and make sure theWidth
is set to300
:ResizeMode="NoResize" SizeToContent="Height" Width="300" FontSize="16"
Add four rows and two columns to the existing
Grid
, and add some controls for a simple data entry dialog as follows:<Grid.RowDefinitions> <RowDefinition...