Class CancelApplicationExitEvent
Represents an event that is raised before the application exits. The exiting of the application can be canceled.
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
Namespace: Loehnert.Lisrt.Framework.Events
Assembly: Loehnert.Lisrt.dll
Syntax
public class CancelApplicationExitEvent
Remarks
Implement the Caliburn.Micro.IHandle<CancelApplicationExitEvent> interface, and add an instance of the implementation to the IEventAggregator.
Examples
This example is an IModule implementation, that can prevent exiting the application.
[Export(typeof(IModule))]
internal class MyAppModule : ModuleBase, IHandle<CancelApplicationExitEvent>
{
[ImportingConstructor]
public MyAppModule(IEventAggregator eventAggregator)
{
eventAggregator.Subscribe(this);
}
public void Handle(CancelApplicationExitEvent message)
{
if (condition)
message.Cancel("The application can not be exited.");
}
}
Properties
CanClose
Gets a value indicating whether the application can be closed.
Declaration
public bool CanClose { get; }
Property Value
Type | Description |
---|---|
Boolean |
Justifications
Gets the justifications why the application cannot be closed.
Declaration
public IEnumerable<string> Justifications { get; }
Property Value
Type | Description |
---|---|
IEnumerable<String> |
Methods
Cancel(String)
Cancels closing of the application.
Declaration
public void Cancel(string justification)
Parameters
Type | Name | Description |
---|---|---|
String | justification | Justification why the application cannot be closed. |
Remarks
The justification
is shown in message box.
Use null or System.String.Empty, if you don't want to show the user a message.