private void formatMarginsMenuItem_Click(object sender, RoutedEventArgs e) { // Instantiate the dialog box var dlg = new MarginsDialogBox { Owner = this, DocumentMargin = documentTextBox.Margin }; // Configure the dialog box // Open the dialog box modally dlg.ShowDialog(); // Process data entered by user if dialog box is accepted if (dlg.DialogResult == true) { // Update fonts documentTextBox.Margin = dlg.DocumentMargin; } }