ZaHaDum1984
ZaHaDum1984

Reputation: 47

Closing WPF Application from a class library (Caliburn.Micro)

I have to develop a WPF application and use Caliburn.Micro to provide MVVM. But this time the view models are located in a separate class library.

All works fine, until I want to close the application. Because the view models are in a separate assembly, they can't access the applicatuion class of the WPF application. So I can't use System.Windows.Application.Current.Shutdown() to close the application, like I did in my former applications.

So how can I exit the application under this conditions?

Info about the existing class hierarchy: ViewModelBase is an abstract base class for all my view models. It derives from Caliburn.Micro.PropertyChangedBase and provides the functionality for IoC, the window manager and the event aggregator.

Upvotes: 3

Views: 1288

Answers (1)

mm8
mm8

Reputation: 169150

Inherit from Caliburn.Micro.Screen, which derives from PropertyChangedBase through ViewAware, and call TryClose().

Or call just call System.Environment.Exit(0).

Upvotes: 7

Related Questions