Skip to main content
.NET 6.0+

ShowViewStrategyBase.ShowMessage(MessageOptions) Method

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public void ShowMessage(
    MessageOptions options
)

Parameters

Name Type Description
options MessageOptions

A MessageOptions object which contains the platform-agnostic and platform-specific notification parameters.

Remarks

XAF displays the following platform-specific notifications:

ASP.NET Core Blazor

A custom Alert component.

A Text Notification in XAF ASP.NET Core Blazor Application, DevExpress

Windows Forms

A Toast Notification with the “Success“ caption.

A Text Notification in XAF Windows Forms Application, DevExpress

ASP.NET Web Forms

A dxToast widget displayed at the specified position.

A Text Notification in XAF ASP.NET Web Forms Application, DevExpress

Use the following technique to show the “{0} task(s) have been successfully updated!“ notification for two seconds when a user clicks the Mark Completed action.

// ...
using DevExpress.ExpressApp;

namespace YourSolutionName.Module.Controllers {
    public class DemoTaskController : ViewController {
        public DemoTaskController() {
            // ...
            markCompletedAction.SelectionDependencyType = SelectionDependencyType.RequireMultipleObjects;
            markCompletedAction.Execute += (s, e) => {
                foreach (DemoTask task in e.SelectedObjects)
                {
                    task.DueDate = DateTime.Now;
                    task.Status = MySolution.Module.BusinessObjects.TaskStatus.Completed;
                    View.ObjectSpace.SetModified(task);
                }
                View.ObjectSpace.CommitChanges();
                View.ObjectSpace.Refresh();
                MessageOptions options = new MessageOptions();
                options.Duration = 2000;
                options.Message = string.Format("{0} task(s) have been successfully updated!", e.SelectedObjects.Count);
                options.Type = InformationType.Success;
                options.Web.Position = InformationPosition.Right;
                options.Win.Caption = "Success";
                options.Win.Type = WinMessageType.Toast;
                options.OkDelegate = () => {
                    IObjectSpace os = Application.CreateObjectSpace(typeof(DemoTask));
                    DetailView newTaskDetailView = Application.CreateDetailView(os, os.CreateObject<DemoTask>());
                    Application.ShowViewStrategy.ShowViewInPopupWindow(newTaskDetailView);
                };
                Application.ShowViewStrategy.ShowMessage(options);
            };
        }
    }
}

In this example, Application is an XafApplication object. Use the Controller.Application, ActionBase.Application or Frame.Application property to access it.

The MessageOptions.OkDelegate is executed when a user clicks the message (or, if the WinMessageOptions.Type property is set to Flyout in a Windows Forms application, when the OK button is clicked). If this delegate is not specified, the message is closed on a click. In the Flyout mode, you can also use MessageOptions.CancelDelegate to provide a handler for the Cancel button.

For more examples of the ShowMessage method usage, refer to the following topic: Text Notifications.

See Also