I'm having problems understanding how WPF app.xaml works. Is it like Main method in winforms programing?
What I want is a MainController class which keeps track of my Window object. For example:
public MainController()
{
_windowMain = new WindowMain(this);
}
public WindowMain GetWindowMain
{
ge开发者_Python百科t { _windowMain; }
}
And so on with all the windows I have in my project. But where should my MainController be initialized?
Check the StartupUri
property of the App.xaml
file. It links in a Window's XAML file within your project to be launched at startup.
If you want to avoid this, then I believe you can override a method in App.xaml.cs
to launch the window explicitly via your controller.
You should understand that the compiler makes a class called 'App' that overrides System.Windows.Application
by compiling your App.xaml
and App.xaml.cs
files. Check the documentation for that class to learn more about the lifecycle management of your WPF application.
精彩评论