Issue with using "MessageBox.Show" in Blazor
Issue to be solve
In Winforms you can have a constructor for a Form, and call a MessageBox.Show or a method that calls the MessageBox.Show
In Blazor, we need to wait for the MessageBox response(in most cases) to continue execution. Why most cases?
As an example, if we have a MessageBox.Show(“Message”), this is just an Expression Statement. We don’t need to wait for a response because it is just a notification, this means that the application does not need to wait for a response.
Proposed solution
What if we just show a notification in a web oriented way? Well, we can use the TelerikNotification component.
This allow us to just show the notification without having to wait for the result or response.
So to achieve this, it is needed to have an event or service to notify TelerikNotification to show and use the correct message. And, by migration, we need to replace the MessageBox.Show by a different statement. The approach is to have a TelerikNotification component in the WMApp component, and this control will be listening for a subscription to show the message
Blazor Desktop Compativility Platform
In the Application.cs, we are building an event to invoke the ShowNotification.
In the migrated code, we can replace a simple MessageBox.Show by a Application.CurrentApplication.ShowNotification()
By doing this, we don’t need to change anything else (initially) in the migrated razor files. Just a replace during migration (and using the DCP changes)
This should be the result when showing the notification in an web environment application:
Last updated