Dialogs
Dialogs are a great way to get the user to make a decision or enter some information. They are also a great way to display information to the user. A set of pre-built dialogs are provided by UraniumUI such as asking multiple or single selection, confirmation and text input. UraniumUI provides an abstraction layer for dialogs with IDialogService
. UraniumUI has 2 different popups implementations which are Community Toolkit and Mopups.
You should pick one of them and add it to your project. UraniumUI will use the popup implementation that you added to your project. If you don't add any popup implementation, UraniumUI will use Modal pages instead of popups.
Available packages
UraniumUI.Dialogs.CommunityToolkit
UraniumUI.Dialogs.Mopups
CommunityToolkit
Add required services in
MauiProgram.cs
Mopups
Install UraniumUI.Dialogs.Mopups
Configure Mopups in
MauiProgram.cs
Add required services in
MauiProgram.cs
Types
There are 4 types of dialogs in UraniumUI package. They are: CheckBox Prompt
, RadioButton Prompt
, Confirmation
and Text Prompt
. They are implemented as extension methods and IDialogService
implementation. You can use them as extension method for any Page or you can use then view injecting IDialogService
to your class.
Extension Method
IDialogService
Injecting
IDialogService
is highly recommended. It'll make your code more testable and makes dialogs libray easily swappable.
RadioButton Prompt
RadioButton prompt can be used to get a single selection input from user. It returns the selected option. It can be used with strings or objects. If you use objects, you can use DisplayMember
parameter to specify the property of the object to be displayed or your object should override ToString()
method.
Usage
The easiest way to use RadioButton prompt is to pass a string array to it. It will return the selected option as a string.
Light | Dark |
---|---|
![]() |
![]() |
Parameters
DisplayRadioButtonPromptAsync
method has 6 parameters. They are:
message
: Message of the dialog. It'll be rendered top of the dialog.selectionSource
: Selection source of the dialog. It can be a string collection or an object collection. If you use objects, you can usedisplayMember
parameter to specify the property of the object to be displayed or your object should overrideToString()
method.selected
: Selected item of the dialog. It'll be automatically selected when dialog is shown.accept
: Accept button text of the dialog. It'll be rendered as the accept button text.cancel
: Cancel button text of the dialog. It'll be rendered as the cancel button text.displayMember
: Display member of the object. It'll be used to specify the property of the object to be displayed or your object should overrideToString()
method.
CheckBox Prompt
CheckBox prompt can be used to get a multiple selection input from user. It returns the selected options. It can be used with strings or objects. If you use objects, you can use DisplayMember
parameter to specify the property of the object to be displayed or your object should override ToString()
method.
Light | Dark |
---|---|
![]() |
![]() |
Usage
The easiest way to use CheckBox prompt is to pass a string array to it. It will return the selected options as a string array.
Parameters
DisplayCheckBoxPromptAsync
method has 6 parameters. They are:
message
: Message of the dialog. It'll be rendered top of the dialog.selectionSource
: Selection source of the dialog. It can be a string collection or an object collection. If you use objects, you can usedisplayMember
parameter to specify the property of the object to be displayed or your object should overrideToString()
method.selectedItems
: Selected items of the dialog. They'll be automatically selected when dialog is shown.accept
: Accept button text of the dialog. It'll be rendered as the accept button text.cancel
: Cancel button text of the dialog. It'll be rendered as the cancel button text.displayMember
: Display member of the object. It'll be used to specify the property of the object to be displayed or your object should overrideToString()
method.
Text Prompt
Text prompt can be used to get a text input from user. It returns the entered text. All parameters are same with MAUI default DisplayPromptAsync
method.
Light | Dark |
---|---|
![]() |
![]() |
Progress
Progress dialog can be used to show a progress dialog to the user. There are 2 types of progress dialogs in UraniumUI. They are blocking and cancellable. Blocking progress dialog will block the UI until it's closed. Cancellable progress dialog will have a cancel button to allow user to cancel the operation. It returns an IDisposable
and it'll be visible until you dispose it. You can use it with using
statement to show a progress dialog.
Light | Dark |
---|---|
![]() |
![]() |
Light | Dark |
---|---|
![]() |
![]() |
Handling Cancellation
You can handle the cancellation of the progress dialog by checking the IsCancellationRequested
property of the CancellationToken
parameter of the DisplayCancellableProgressAsync
method.
You can handle with registering an action to the
CancellationToken
.You can handle at the end of the operation by checking the
IsCancellationRequested
property of theCancellationToken
.You can even cancel the long running Task operation when user cancels the operation: