简体   繁体   English

WPF App.xaml在不同的Assembly中

[英]WPF App.xaml in different Assembly

I want to setup a WPF Application. 我想设置一个WPF应用程序。 But instead of using the entry point of the application to a App.xaml itself, I've to projects. 但是,不是将应用程序的入口点用于App.xaml本身,而是使用项目。

The first projects is a Windows Application and has a normale Main function. 第一个项目是Windows应用程序,并具有normale Main功能。 And I've an additional project (WPF control library), that has the App.xaml, windows, controls and all it needs. 我还有一个额外的项目(WPF控件库),它有App.xaml,windows,控件和它所需要的一切。

The main method start the Application like this: 主要方法启动应用程序,如下所示:

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

Where Application is a class in the library: Application是库中的类:

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

Where app is my App.xaml. app是我的App.xaml。 App.xaml defines a startup uri MainWindow.xaml . App.xaml定义了一个启动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). 我无法在第一个程序集中设置App.xaml,因为我要支持多个窗口框架(WPF,Gtk#等)。 Any suggestions how to manage this scenario? 有关如何管理此方案的任何建议吗?

Just add 只需添加

app.InitializeComponent();

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM