开发者

How to convert WPF project so it can be used as a class library by a separate exe

has anyone ever tried or felt the need to start their application in a stand alone exe and use WPF as just another DLL, rather than having the Main method within it?

The advantages I see are logical separation, and being able to set up a factory etc outside the WPF code, thus reducing assembly dependencies.

I have tried doing this and can get so far e.g. by setting the WPF project setting to 'class library', removing the startupuri from app.xaml and setting its build action to compile etc, and either calling app.run from the separate exe or having a method within the main window call this.

However, the resources (e.g. styles defined for buttons) in app.xaml appear not to have any effect when I do this. Converting the WPF project back to its default settings (startupuri etc) get the resources working again, but I'm not sure where the problem lies开发者_开发百科. Any ideas?


You can create Control libraries (Custom Control Libraries or User Control Libraries) to separate reusable controls from the application. But as its called they are Control Libraries. You can set Resources to UserControls, Pages, ... but not on Applications, cause they are not known in a Control library.

The generic XAML for your Controls should not be stored in the resources of the app.xaml, but in the Themes/Generic.xaml file.

User Control Library vs Custom Control library

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜