Blazing.Dialog 1.0.0

dotnet add package Blazing.Dialog --version 1.0.0
NuGet\Install-Package Blazing.Dialog -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Blazing.Dialog" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Blazing.Dialog --version 1.0.0
#r "nuget: Blazing.Dialog, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Blazing.Dialog as a Cake Addin
#addin nuget:?package=Blazing.Dialog&version=1.0.0

// Install Blazing.Dialog as a Cake Tool
#tool nuget:?package=Blazing.Dialog&version=1.0.0

Blazing.Dialog

Open dialogs (bootstrap modals) in blazor with awaitable calls.

Nuget

Things to note:

  1. As mentioned this uses bootstrap modals (bootstrap 4+). This means it is dependent on jquery and bootstrap javascript references that isn't imported in the default blazor templates. Make sure you add these imports. Here are some useful links:

    jQuery: https://code.jquery.com/

    bootstrap: https://www.bootstrapcdn.com/

    bootstrap (older versions): https://www.bootstrapcdn.com/legacy/bootstrap/

  2. This nuget aims at functionality and doesn't come with a any UI/css out of the box. You can use any boiler-plate boostrap modal code.

Installation:

  1. Install the nuget package

    install-package Blazing.Dialog
    
  2. Import the script file in your index.html

    <script src="_content/Blazing.Dialog/scripts.js"></script>
    
  3. In the _imports.razor file, add the following import:

    @using Blazing.Dialog
    

Usage:

C# code

Create a new instance of the DialogAccess class;

readonly DialogAccess dialog = new DialogAccess();

You can now open this dialog by calling dialog.OpenAsync(). OpenAsync will only work when dialog is bound to a dialog UI (next section)

// do something before the dialog is opened
await dialog.OpenAsync();
// do something after the  is closed

You can programatically close the dialog by calling dialog.CancelAsync() at any time.

It is often helpful if the OpenAsync function returned some data relating to a selection in the dialog. Here are some examples

  • A confirmation dialog can return a bool. It can return true only when the user clicks "Yes".
  • A dialog can display a list of options and can return a string representing the selection.
  • A dialog can display a list of options and return an int representing the Id of the selection.

All above examples can be found in the blazor sample project in this repo.

To make the OpenAsync function return a type of your choice, you can use the generic DialogAccess class. Your declaration would change to:

readonly DialogAccess<string> dialog = new DialogAccess<string>();

Next, to make the OpenAsync complete and return a specific string, you can call dialog.CompleteAsync("my response") while the dialog is still open. This code normally goes in a blazor onclick event. See the "ConfirmationDialog.razor" and "OptionsDialog.razor" pages in the blazor sample for detailed examples.

Blazor code for binding UI

Add the DialogControl component and assign the Access property to the dialog field created above.

<DialogControl Access=dialog>

</DialogControl>

The DialogControl creates a div with a "modal" class. You can add any boiler plate code "modal-content" code for bootstrap 4 modals. Here is one sample: https://www.w3schools.com/bootstrap4/bootstrap_modal.asp.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 554 12/30/2019

- OpenAsync functionality for bootstrap modals
     - OpenAsync functions can return any generic type
     - Properties and events meant for binding with bootstrap modals