WPF中针对不同客户的不同GUI定义

[英]Different GUI definitions in a WPF for different customers


I have a project which is customized for different customers, only in the UI. The code is exactly the same for all.

我有一个为不同客户定制的项目,仅在UI中。代码完全相同。

Right now, I copy the whole project to get a different UI for the customer (button alignment, mostly). Is it possible to swap only the UI definitions / specify which to use during build, so I do not need to copy the whole project?

现在,我复制整个项目以获得客户的不同UI(主要是按钮对齐)。是否可以只交换UI定义/指定在构建期间使用哪些,所以我不需要复制整个项目?

Something like:

就像是:

UI_cust1
UI_cust2
UI_cust3
...

Build with

建立与

UI_cust2

2 个解决方案

#1


0  

Can you provide a configuration provider type of class which reads values from an XML file?

您是否可以提供从XML文件读取值的配置提供程序类型?

You can then edit the XML per customer.

然后,您可以按客户编辑XML。

I think if you create the provider as a data source and then include a converter which takes a key as a parameter to return the specific value, you should be able to create keys for each property you want to control.

我认为如果您将提供程序创建为数据源,然后包含一个转换器,该转换器将一个键作为参数来返回特定值,您应该能够为要控制的每个属性创建键。

I have done similar in the past as a localisation and theming solution and it worked. I haven't got code immediately to hand unfortunately.

我在过去做过类似的本地化和主题解决方案并且它起作用了。不幸的是,我没有立即得到代码。

#2


0  

I would recommend you to make it a habit to use an IOC (Invertion of Control) container in all your projects. It forces you to use Dependency Injection, which gives you a more modular architecture.

我建议你养成在所有项目中使用IOC(Invertion of Control)容器的习惯。它会强制您使用依赖注入,这为您提供了更加模块化的体系结构。

Most IOC containers support XML files for registering dependencies. In that way you only need to change the XML configuration file for different customers. Voilà, you now have a different behavior/appearance of your application for each customer.

大多数IOC容器都支持XML文件以注册依赖项。这样,您只需要为不同的客户更改XML配置文件。 Voilà,您现在可以为每个客户提供不同的应用程序行为/外观。

As a bonus, your application will be easier to test. Preferable you use TDD (Test Driven Development) while building your application, which will make the whole IOC/DI experience feel very natural.

作为奖励,您的应用程序将更容易测试。在构建应用程序时,最好使用TDD(测试驱动开发),这将使整个IOC / DI体验感觉非常自然。

A good IOC container to start with is AutoFac, a very simple, yet powerful container.

一个好的IOC容器是AutoFac,一个非常简单但功能强大的容器。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2014/07/28/fd1e41c12ba18668dc1a02599b45a3ca.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号