I have a console project, but now I need to put an user interface on. So I’m using the 3 tier model (presentation, business, access data).
In my method Main() I call to presentation layer (like app in Window form or Wpf), so, in the presentation layer is the interaction with user through CONSOLE.
Now I add a window called “UserInterface.xaml” in the presentation layer to use instead of console. Because should be with INTERFACE not console.
I have observed that in MainWindow the called is with MainWindow.Show();
But I don’t know how to call my “UserInterface.xaml”, because has no .Show() method.
This is my method Main:
public static void Main()
{
MainWindow.Show(); // THIS IS WITH MainWindow.xaml
UserInterface.??? // THIS IS MY CASE WITH UserInterface.xaml
}
So can somebody tell me how I can call my window from the Main method??
You definitely got started with the wrong project template. To make a WPF window visible and interactive, you have to follow the rules for a UI thread. Which includes marking the main thread of your app as an STA thread and pumping a message loop. Like this:
Beware that Application.Run() is a blocking call, it will not return until the user closes the main window. This is a rather inevitable consequence of the way Windows works.