Replies: 1 comment
|
I'd do something like (completely untested, but you get the general idea): public class CloseAllWindowsService
{
private readonly Application application;
private readonly Action openRootView;
public CloseAllWindowsService(Application application, Action openRootView)
{
this.application = application;
openRootView = openRootView;
}
public void CloseAllWindows()
{
foreach (Window window in application.Windows)
{
window.Close();
}
openRootView();
}
}Then in your bootstrapper: protected override void ConfigureIoC(StyletIoCBuilder builder)
{
builder.Bind<CloseAllWindowsService>().ToInstance(new CloseAllWindowsService(Application, Launch));
}Then in your VM: public class MyViewModel : Screen
{
private readonly CloseAllWindowsService closeAllWindowsService;
public MyViewModel(CloseAllWindowsService closeAllWindowsService)
{
this.closeAllWindowsService = closeAllWindowsService;
}
public void LogOut()
{
closeAllWindowsService.CloseAllWindows();
}
} |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello friends.
Essentially, what I am trying to do is for the user to log out of my application.
I am not at the moment tracking the logged in user throughout the application, so I thought I'd just close all open views and re-open the root view which is the log in window.
I have set my application up according to how it's described in the documentation.
I am using the following:
And this works, but I am looking for a better solution. I don't know if this way of doing it will work when I later on implement user tracking in my application.
I would like to implement the Bootstrapper.Launch() method, but by default it's set to
protected override void- I don't know how to access it.A bit of a messy and open question, appreciate any who take the time to write a comment :-)
All reactions