I have a Window, and there are three types of content that can be displayed (they are all of UserControl type):
- Login view
- App view
- Error reporting
What's the most appropriate way to switch between these? My thought was to pass instance of Window in the constructor and then addressing it's content.
Content = new LoginView(this);
And then change the content from LoginView,
public LoginView(Window wnd){
InitializeComponents();
wnd.Content = new MainView(wnd);
}
But this wouldn't update the Window's content. Is it caused by the caller (LoginView) being the window's current content? If that's the case, what would be the proper way to handle such situation?
Also note that the snippet provided doesn't include any logic. I just left it as simple as required to demonstrate the issue I'm facing.
Basically the connection between those controls is such:
Login view - when the application starts - when the application window sends a request (to the server) that returns unauthorized
App view - handles all the application's features
Error view - replaces app/login view in case of an error and informs user about what to do