In This Article

Extension Methods

One of the benefits of the builder pattern is that it's easy to extend the builder class with extension methods.

Important

Import the ActiproSoftware.Windows.Extensions namespace to include the built-in extension methods.

Exception Prompt

A common scenario in application development is to catch an Exception and prompt the user that an error occurred.

Screenshot

UserPromptControl configured to display details of an exception with stack trace expanded

The ForException extension method can be used to pre-configure the UserPromptBuilder to display an exception. This includes the error status image, a summary of the error, and a detailed stack trace in the expanded information with a link to copy the stack trace to the clipboard.

The following sample demonstrates how easily a rich exception prompt can be created and shown to the user:

try {
	//
}
catch (Exception ex) {
	UserPromptBuilder.Configure()
		.ForException(ex, "Custom header text.")
		.Show();
}
Tip

See the Localization topic for details on how to customize the string resources used for exception prompt.

Tag Property

The UserPromptBuilder.Tag property can be used to store an arbitrary object value on the builder, and this can be useful for extension methods that need to store custom values while building the prompt. Use the UserPromptBuilder.WithTag method to assign values to this property.