Class DialogService. Contains various methods with options to open and close dialogs. Should be added as scoped service in the application services and RadzenDialog should be added in application main layout.
Object
Namespace: Radzen
Assembly: Radzen.Blazor.dll
public class DialogService@inject DialogService DialogService
<RadzenButton Text="Show dialog with inline Blazor content" Click=@ShowInlineDialog />
@code {
async Task ShowInlineDialog()
{
var result = await DialogService.OpenAsync("Simple Dialog", ds =>
@<div>
<p Style="margin-bottom: 1rem">Confirm?</p>
<div class="row">
<div class="col-md-12">
<RadzenButton Text="Ok" Click="() => ds.Close(true)" Style="margin-bottom: 10px; width: 150px" />
<RadzenButton Text="Cancel" Click="() => ds.Close(false)" ButtonStyle="ButtonStyle.Base" Style="margin-bottom: 10px; width: 150px"/>
<RadzenButton Text="Refresh" Click="(() => { orderID = 10249; ds.Refresh(); })" ButtonStyle="ButtonStyle.Info" Style="margin-bottom: 10px; width: 150px"/>
Order ID: @orderID
</div>
</div>
</div>);
Console.WriteLine($"Dialog result: {result}");
}
}Initializes a new instance of the DialogService class.
public DialogService(NavigationManager uriHelper, Microsoft.JSInterop.IJSRuntime jsRuntime)
| Type | Name | Description |
|---|---|---|
| NavigationManager | uriHelper | The URI helper. |
| Microsoft.JSInterop.IJSRuntime | jsRuntime | IJSRuntime instance. |
Displays a alert dialog.
public virtual Task<bool?> Alert(string message, string title, AlertOptions options, Threading.CancellationToken? cancellationToken)
| Type | Name | Description |
|---|---|---|
| string | message | The message displayed to the user. |
| string | title | The text displayed in the title bar of the dialog. |
| AlertOptions | options | The options. |
| Threading.CancellationToken? | cancellationToken | The cancellation token. |
| Type | Description |
|---|---|
| Task<bool?> | true if the user clicked the OK button, false otherwise. |
Displays a alert dialog.
public virtual Task<bool?> Alert(RenderFragment message, string title, AlertOptions options, Threading.CancellationToken? cancellationToken)
| Type | Name | Description |
|---|---|---|
| RenderFragment | message | The message displayed to the user. |
| string | title | The text displayed in the title bar of the dialog. |
| AlertOptions | options | The options. |
| Threading.CancellationToken? | cancellationToken | The cancellation token. |
| Type | Description |
|---|---|
| Task<bool?> | true if the user clicked the OK button, false otherwise. |
Closes the side dialog
public virtual void Close(object result)
| Type | Name | Description |
|---|---|---|
| object | result | The result of the Dialog |
Closes the side dialog
public virtual void CloseSide(object result)
| Type | Name | Description |
|---|---|---|
| object | result | The result of the Dialog |
Closes the side dialog and waits for the closing animation to finish.
public Task CloseSideAsync(object result)
| Type | Name | Description |
|---|---|---|
| object | result | The result of the Dialog |
| Type | Description |
|---|---|
| Task |
Displays a confirmation dialog.
public virtual Task<bool?> Confirm(string message, string title, ConfirmOptions options, Threading.CancellationToken? cancellationToken)
| Type | Name | Description |
|---|---|---|
| string | message | The message displayed to the user. |
| string | title | The text displayed in the title bar of the dialog. |
| ConfirmOptions | options | The options. |
| Threading.CancellationToken? | cancellationToken | The cancellation token. |
| Type | Description |
|---|---|
| Task<bool?> | true if the user clicked the OK button, false otherwise. |
Displays a confirmation dialog.
public virtual Task<bool?> Confirm(RenderFragment message, string title, ConfirmOptions options, Threading.CancellationToken? cancellationToken)
| Type | Name | Description |
|---|---|---|
| RenderFragment | message | The message displayed to the user. |
| string | title | The text displayed in the title bar of the dialog. |
| ConfirmOptions | options | The options. |
| Threading.CancellationToken? | cancellationToken | The cancellation token. |
| Type | Description |
|---|---|
| Task<bool?> | true if the user clicked the OK button, false otherwise. |
Opens a dialog with the specified arguments.
public virtual void Open(string title, Dictionary<string, object> parameters, DialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the dialog. |
| Dictionary<string, object> | parameters | The dialog parameters. |
| DialogOptions | options | The dialog options. |
Opens a dialog with the specified arguments.
public virtual void Open(string title, Type componentType, Dictionary<string, object> parameters, DialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the dialog. |
| Type | componentType | |
| Dictionary<string, object> | parameters | The dialog parameters. |
| DialogOptions | options | The dialog options. |
Opens a dialog with the specified arguments.
public virtual void Open(string title, RenderFragment<DialogService> childContent, DialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the dialog. |
| RenderFragment<DialogService> | childContent | |
| DialogOptions | options | The dialog options. |
Opens a dialog with the specified arguments.
public virtual Task<object> OpenAsync(string title, Dictionary<string, object> parameters, DialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the dialog. |
| Dictionary<string, object> | parameters | The dialog parameters. Passed as property values of T. |
| DialogOptions | options | The dialog options. |
| Type | Description |
|---|---|
| Task<object> | The value passed as argument to Object). |
Opens a dialog with the specified arguments.
public virtual Task<object> OpenAsync(string title, Type componentType, Dictionary<string, object> parameters, DialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the dialog. |
| Type | componentType | |
| Dictionary<string, object> | parameters | The dialog parameters. Passed as property values of T. |
| DialogOptions | options | The dialog options. |
| Type | Description |
|---|---|
| Task<object> | The value passed as argument to Object). |
Opens a dialog with the specified arguments.
public virtual Task<object> OpenAsync(string title, RenderFragment<DialogService> childContent, DialogOptions options, Threading.CancellationToken? cancellationToken)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the dialog. |
| RenderFragment<DialogService> | childContent | |
| DialogOptions | options | The dialog options. |
| Threading.CancellationToken? | cancellationToken |
| Type | Description |
|---|---|
| Task<object> | The value passed as argument to Object). |
Opens a dialog with the specified arguments.
public virtual Task<object> OpenAsync(RenderFragment<DialogService> titleContent, RenderFragment<DialogService> childContent, DialogOptions options, Threading.CancellationToken? cancellationToken)
| Type | Name | Description |
|---|---|---|
| RenderFragment<DialogService> | titleContent | |
| RenderFragment<DialogService> | childContent | |
| DialogOptions | options | The dialog options. |
| Threading.CancellationToken? | cancellationToken |
| Type | Description |
|---|---|
| Task<object> | The value passed as argument to Object). |
Opens a side dialog with the specified arguments
public void OpenSide(string title, Dictionary<string, object> parameters, SideDialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the side dialog. |
| Dictionary<string, object> | parameters | The dialog parameters. Passed as property values of T |
| SideDialogOptions | options | The side dialog options. |
Opens a side dialog with the specified arguments
public void OpenSide(string title, Type componentType, Dictionary<string, object> parameters, SideDialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the side dialog. |
| Type | componentType | |
| Dictionary<string, object> | parameters | The dialog parameters. Passed as property values of T |
| SideDialogOptions | options | The side dialog options. |
Opens a side dialog with the specified arguments
public Task<object> OpenSideAsync(string title, Dictionary<string, object> parameters, SideDialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the side dialog. |
| Dictionary<string, object> | parameters | The dialog parameters. Passed as property values of T |
| SideDialogOptions | options | The side dialog options. |
| Type | Description |
|---|---|
| Task<object> | A task that completes when the dialog is closed or a new one opened |
Opens a side dialog with the specified arguments
public Task<object> OpenSideAsync(string title, Type componentType, Dictionary<string, object> parameters, SideDialogOptions options)
| Type | Name | Description |
|---|---|---|
| string | title | The text displayed in the title bar of the side dialog. |
| Type | componentType | |
| Dictionary<string, object> | parameters | The dialog parameters. Passed as property values of T |
| SideDialogOptions | options | The side dialog options. |
| Type | Description |
|---|---|
| Task<object> | A task that completes when the dialog is closed or a new one opened |
Occurs when a new dialog is open.
public event Action<string, Type, Dictionary<string, object>, DialogOptions> OnOpenRaises the Close event for the side dialog
public event Action<object> OnSideCloseRaises the Open event for the side dialog
public event Action<Type, Dictionary<string, object>, SideDialogOptions> OnSideOpen