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
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.
Example 1: Showing RadAlert with DialogParameters
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
}
}
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
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.
Example 3: Handling RadAlert's Closed event
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.
Example 4: Showing RadConfirm
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
}
}
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
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.
Example 6: Showing RadPrompt
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 + "!";
}
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
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.
Example 8: Showing RadPrompt with a default result
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.