# Predefined Dialogs

The **RadWindow** provides you with a set of predefined dialog windows that are an easy way to handle a few scenarios:

* Alert the user with a certain message

* Prompt the user for certain information

* Allow the user to confirm an action

These windows can be shown using the respective static methods of the **RadWindow** class:

* **Alert()** - 3 overloads

* **Confirm()** - 2 overloads

* **Prompt()** - 3 overloads

> All of the predefined windows are modal.

Each of the methods has an overload that takes an object of type **DialogParameters** as an argument. The **DialogParameters** class has members similar to the specific ones of the **RadWindow**. This allows you to configure the predefined dialogs via the argument of the method.

Here is a list of the **DialogParameters** class members:

* **CancelButtonContent**

* **Closed**

* **Content**

* **ContentStyle**

* **DefaultPromptResultValue**

* **Header**

* **IconContent**

* **ModalBackground**

* **OkButtonContent**

* **Opened**

* **Owner**

* **Theme**

* **WindowStyle**

* **DefaultFocusedButton**

For more info about the class read [here](https://docs.telerik.com/devtools/wpf/api/telerik.windows.controls.dialogparameters).

## Alert

The alert dialog window allows you to alert the user with a certain message. It is shown by calling the **Alert()** method of the static **RadWindow** class. It can take one of the following argument groups:

* **DialogParameters dialogParameters** - an object of type **DialogParameters**.

**Example 1: Showing RadAlert with DialogParameters**

```C#
void ShowAlert()
{
    RadWindow.Alert(new DialogParameters()
    {
        Content = "Hello",
        Closed = this.OnClosed

    });
}
private void OnClosed(object sender, WindowClosedEventArgs e)
{
    var result = e.DialogResult;
    if (result == true)
    {
        // handle confirmation
    }
}
```

```VB.NET
	RadWindow.Alert(New DialogParameters() With {
		.Content = "Hello",
		.Closed = AddressOf Me.OnClosed
	})

	Private Sub OnClosed(sender As Object, e As WindowClosedEventArgs)
	    Dim result = e.DialogResult
		If result = True Then
			' handle confirmation
		End If
	End Sub
```

* **object content** - an object that represents the content.

**Example 2: Showing RadAlert without DialogParameters**

```C#
RadWindow.Alert("Hello");
```

```VB.NET
	RadWindow.Alert("Hello")
```

* **object content, EventHandler\<WindowsClosedEventArgs> closed** - an object, that represents the content and an event handler that should handle the **Closed** event of the **RadWindow**.

**Example 3: Handling RadAlert's Closed event**

```C#
public void ShowAlert()
{
    RadWindow.Alert("Hello", this.OnClosed);
}
private void OnClosed(object sender, WindowClosedEventArgs e)
{
    var result = e.DialogResult;
    if (result == true)
    {
        // handle confirmation
    }
}
```

```VB.NET
	Public Sub ShowAlert()
	    RadWindow.Alert("Hello", AddressOf Me.OnClosed)
	End Sub
	Private Sub OnClosed(sender As Object, e As WindowClosedEventArgs)
	    Dim result = e.DialogResult
		If result = True Then
			' handle confirmation
		End If
	End Sub
```

![RadAlert](https://www.telerik.com/products/wpf/documentation/assets/1b8e41bf4e916f3d5b492da9ecd6a78c/radwindow_features_predefined_windows_01.png)

> The **DialogResult** of the WindowClosedEventArgs will be **True** if the user has pressed **OK** and **null** if the user clicked the **close button** of the window. The **PromptResult** property will always be **null**.

## Confirm

The confirm dialog window allows the user to confirm an action. It is shown by calling the **Confirm()** method of the static **RadWindow** class. It can take one of the following argument groups:

* **DialogParameters dialogParameters** - an object of type **DialogParameters**.

**Example 4: Showing RadConfirm**

```C#

void ShowConfirm()
{
    RadWindow.Confirm(new DialogParameters()
    {
        Content = "Are you sure ?",
        Closed = this.OnClosed,
    });
}
private void OnClosed(object sender, WindowClosedEventArgs e)
{
    var result = e.DialogResult;
    if (result == true)
    {
        // handle confirmation
    }
}
```

```VB.NET
	RadWindow.Confirm(New DialogParameters() With {
		.Content = "Are you sure ?",
		.Closed = AddressOf Me.OnClosed
	})

	Private Sub OnClosed(sender As Object, e As WindowClosedEventArgs)
	    Dim result = e.DialogResult
		If result = True Then
			' handle confirmation
		End If
	End Sub
```

* **object content, EventHandler\<WindowsClosedEventArgs> closed** - an object that represents the content and an event handler that should handle the **Closed** event of the **RadWindow**.

**Example 5: Handling RadConfirm's Closed event**

```C#
public void ShowConfirm()
{
    RadWindow.Confirm("Are you sure?", this.OnClosed);
}
private void OnClosed(object sender, WindowClosedEventArgs e)
{
    var result = e.DialogResult;
    if (result == true)
    {
        // handle confirmation
    }
}
```

```VB.NET
	Public Sub ShowConfirm()
	    RadWindow.Confirm("Are you sure?", AddressOf Me.OnClosed)
	End Sub
	Private Sub OnClosed(sender As Object, e As WindowClosedEventArgs)
	    Dim result = e.DialogResult
		If result = True Then
			' handle confirmation
		End If
	End Sub
```

![RadConfirm](https://www.telerik.com/products/wpf/documentation/assets/bd3912310a2545649ee262483186873e/radwindow_features_predefined_windows_03.png)

> The **DialogResult** of the WindowClosedEventArgs will be **True** if the user has pressed **OK**, **False** if the user clicked **Cancel** and **null** if the user clicked the **close button** of the window. The **PromptResult** property will always be **null**.

## Prompt

The prompt dialog window allows the user to input information. It is shown by calling the **Prompt()** method of the static **RadWindow** class. It can take one of the following argument groups:

* **DialogParameters dialogParameters** - an object of type **DialogParameters**.

**Example 6: Showing RadPrompt**

```C#
void ShowPrompt()
{
    RadWindow.Prompt(new DialogParameters()
    {
        Content = "Enter your name:",
        Closed = this.OnClosed
    });
}
private void OnClosed(object sender, WindowClosedEventArgs e)
{
    var result = e.PromptResult;
    var message = "Hello " + result + "!";
}
```

```VB.NET
	RadWindow.Prompt(New DialogParameters() With {
		.Content = "Enter your name:",
		.Closed = AddressOf Me.OnClosed
	})

	Private Sub OnClosed(sender As Object, e As WindowClosedEventArgs)
		Dim result = e.PromptResult
		Dim message = "Hello " & result & "!"
	End Sub
```

* **object content, EventHandler\<WindowsClosedEventArgs> closed** - an object that represents the content and an event handler that should handle the **Closed** event of the **RadWindow**.

**Example 7: Handling RadPrompt's Closed event**

```C#
public void ShowPrompt()
{
    RadWindow.Prompt("Enter your name:", this.OnClosed);
}
private void OnClosed(object sender, WindowClosedEventArgs e)
{
    var result = e.PromptResult;
    var message = "Hello " + result + "!";
}
```

```VB.NET
	Public Sub ShowPrompt()
	    RadWindow.Prompt("Enter your name:", AddressOf Me.OnClosed)
	End Sub
	Private Sub OnClosed(sender As Object, e As WindowClosedEventArgs)
		Dim result = e.PromptResult
		Dim message = "Hello " & result & "!"
	End Sub
```

* **object content, EventHandler\<WindowsClosedEventArgs> closed, string defaultPropmptResult** - an object that represents the content, an event handler that should handle the **Closed** event of the **RadWindow** and a default result value.

**Example 8: Showing RadPrompt with a default result**

```C#
public void ShowPrompt()
{
    RadWindow.Prompt("Enter your name:", this.OnClosed, "John Doe");
}
private void OnClosed(object sender, WindowClosedEventArgs e)
{
    var result = e.PromptResult;
    var message = "Hello " + result + "!";
}
```

```VB.NET
	Public Sub ShowPrompt()
	    RadWindow.Prompt("Enter your name:", AddressOf Me.OnClosed, "John Doe")
	End Sub
	Private Sub OnClosed(sender As Object, e As WindowClosedEventArgs)
		Dim result = e.PromptResult
		Dim message = "Hello " & result & "!"
	End Sub
```

> The **DialogResult** of the WindowClosedEventArgs will be **True** if the user has pressed **OK**, **False** if the user clicked **Cancel** and **null** if the user clicked the **close button** of the window. The **PromptResult** property will hold the value entered by the user if they clicked **OK** and **null** otherwise.

![RadPrompt](https://www.telerik.com/products/wpf/documentation/assets/ac1c866d69620fcd883a821610a42ebe/radwindow_features_predefined_windows_02.png)

## Styling the Predefined Windows

If you want to change the appearance of the predefined window, you have to show it by calling the overload that takes a **DialogParameters** object as an argument. Create an appropriate style and set it to its **WindowStyle** property. To learn more read [here](https://www.telerik.com/products/wpf/documentation/controls/radwindow/styles-and-templates/styling-the-predefined-windows).

## Setting the Default Focused Button

Since the **2019.1.415** internal build version and the **R2 2019** official release, the DialogParameters expose a **DefaultFocusedButton** property. It allows you to set the button that will be focused by default when the modal window is shown. This property is of type [ResponseButton](https://docs.telerik.com/devtools/wpf/api/telerik.windows.controls.responsebutton).

**Example 9: Setting the default focused button of a RadConfirm to Cancel**

```C#
DialogParameters parameters = new DialogParameters();
parameters.Content = "Are you sure?";
parameters.DefaultFocusedButton = ResponseButton.Cancel;
RadWindow.Confirm(parameters);
```

```VB.NET
	Dim parameters As New DialogParameters()
	parameters.Content = "Are you sure?"
	parameters.DefaultFocusedButton = ResponseButton.Cancel
	RadWindow.Confirm(parameters)
```

## See Also

* [Working with RadWindow](https://www.telerik.com/products/wpf/documentation/controls/radwindow/features/working-with-radwindow)

* [Styling the Predefined Windows](https://www.telerik.com/products/wpf/documentation/controls/radwindow/styles-and-templates/styling-the-predefined-windows)

* [RadWindowManager](https://www.telerik.com/products/wpf/documentation/controls/radwindow/features/radiwindowmanager)
