WPF App.xaml在不同的程序集中 [英] WPF App.xaml in different Assembly
问题描述
我想设置一个WPF应用程序.但是,我不必使用应用程序到App.xaml本身的入口点,而必须进行项目设计.
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.
第一个项目是Windows应用程序,具有常规Main函数.我还有一个附加项目(WPF控件库),其中包含App.xaml,窗口,控件及其所有需要的内容.
The first projects is a Windows Application and has a normale 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();
}
}
应用程序是我的App.xaml. App.xaml定义了启动uri MainWindow.xaml
.但是,如果我运行该应用程序,则该窗口永远不会显示,而是该应用程序本身运行.
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.
我无法在第一个程序集中设置App.xaml,因为我必须支持多个窗口框架(WPF,Gtk#等).关于如何管理这种情况有什么建议吗?
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?
推荐答案
只需添加
app.InitializeComponent();
在App app = new App();
和app.Run();
之间.
这篇关于WPF App.xaml在不同的程序集中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!