开发者

WPF App.xaml in different Assembly

开发者 https://www.devze.com 2023-01-31 03:00 出处:网络
I want to setup a WPF Application. But instead of using the entry point of the application to a App.xaml itself, I\'ve to projects.

I want to setup a WPF Application. But instead of using the entry point of the application to a App.xaml itself, I've to projects.

The first projects is a Windows Application and has a n开发者_如何学Goormale Main function. And I've an additional project (WPF control library), that has the App.xaml, windows, controls and all it needs.

The main method start the Application like this:

[STAThread]
static void Main()
{
     Application.Run();
}

Where Application is a class in the library:

public static class Application
{
      public void Run()
      {
            App app = new App();
            app.Run();
      }
}

Where app is my App.xaml. App.xaml defines a startup uri MainWindow.xaml. But if I run the application, the window is never displayed, but the application itself runs.

I can not setup the App.xaml in the first assembly, because I've to support multiple window frameworks (WPF, Gtk#, etc). Any suggestions how to manage this scenario?


Just add

app.InitializeComponent();

between App app = new App(); and app.Run();.

0

精彩评论

暂无评论...
验证码 换一张
取 消