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 methods of the static 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

For more info about the class read here.

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.

RadWindow.Alert(new DialogParameters() 
{ 
    Content = "Hello" 
}); 
Dim parameters As New DialogParameters() 
parameters.Content = "Hello" 
RadWindow.Alert(parameters) 
  • object content - an object that represents the content.

RadWindow.Alert("Hello"); 
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.

public void ShowAlert() 
{ 
    RadWindow.Alert("Hello", this.OnClosed); 
} 
private void OnClosed(object sender, WindowClosedEventArgs e) 
{ 
    var result = e.DialogResult; 
    if (result == true) 
    { 
        // handle confirmation 
    } 
} 
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 

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.

DialogParameters parameters = new DialogParameters(); 
parameters.Content = "Are you sure?"; 
RadWindow.Confirm(parameters); 
Dim parameters As New DialogParameters() 
parameters.Content = "Are you sure?" 
RadWindow.Confirm(parameters) 
  • object content, EventHandler<WindowsClosedEventArgs> closed - an object that represents the content and an event handler that should handle the Closed event of the RadWindow.

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 
    } 
} 
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 

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.

DialogParameters parameters = new DialogParameters(); 
parameters.Content = "Enter your name:"; 
RadWindow.Prompt(parameters); 
Dim parameters As New DialogParameters() 
parameters.Content = "Enter your name:" 
RadWindow.Prompt(parameters) 
  • object content, EventHandler<WindowsClosedEventArgs> closed - an object that represents the content and an event handler that should handle the Closed event of the RadWindow.

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 + "!"; 
} 
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.

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 + "!"; 
} 
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.

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.

See Also

In this article
Not finding the help you need? Improve this article