Class CancelApplicationExitEvent
Represents an event that is raised before the application exits. The exiting of the application can be canceled.
public class CancelApplicationExitEvent
- Inheritance
-
CancelApplicationExitEvent
- Inherited Members
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.");
}
}
Remarks
Implement the Caliburn.Micro.IHandle<CancelApplicationExitEvent> interface, and add an instance of the implementation to the IEventAggregator.
Properties
CanClose
Gets a value indicating whether the application can be closed.
public bool CanClose { get; }
Property Value
Justifications
Gets the justifications why the application cannot be closed.
public IEnumerable<string> Justifications { get; }
Property Value
Methods
Cancel(string)
Cancels closing of the application.
public void Cancel(string justification)
Parameters
justification
stringJustification why the application cannot be closed.
Remarks
The justification
is shown in message box.
Use null or Empty, if you don't want to show the user a message.