可插拔应用程序中WPF中的静态资源 [英] Static resources in WPF in pluggable application

查看:149
本文介绍了可插拔应用程序中WPF中的静态资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究企业WPF应用程序,并且遇到一些静态资源问题:全局定义的样式和转换器.

I am currently working on an enterprise WPF application and I am experiencing some issues with static resources: globally defined styles and converters.

应用程序是这样工作的:

The application works this way:

  • 有一个共享的主机WPF应用程序,用作不同团队开发的组件的主机(这是PRISM应用程序,MEF用于导入插件)
  • 每个团队都可以通过创建新的dll添加插件,但不能修改其他团队的dll
  • 不能对宿主应用程序进行任何更改

我的团队负责几个插件,我们需要添加更多功能,但是我们想知道解决问题的最佳方法是什么.

My team is in charge of few plugins and we need to add more functionalities but we are wondering what is the best way to solve our problem.

在简单的(标准?)WPF应用程序中,我们将在App.xaml文件中定义样式,并且所有xaml UserControl或Windows都可以在设计时轻松地链接到它们,当然也可以在运行时链接到它们.

In a simple (standard?) WPF application, we would have styles defined in the App.xaml file and all the xaml UserControls or Windows would be able to link to them at design time easily and of course at runtime.

但是现在,尽管我设法使样式在运行时工作,但我无法在设计时使样式工作,这导致了两个主要问题:

But now, while I managed to get the styles to work during runtime, I cannot have them working at design time and it is causing two major issues:

  1. 我看不到IDE中的样子
  2. 当我引用转换器时,IDE会抱怨,但我无法知道它在运行时如何工作.

如何导入StaticResources并同时在我的IDE中工作?

How do I get StaticResources to be imported and, at the same time, work in my IDE?

如果不可能,我还可以采取哪些其他策略来克服这些问题?

If not possible, what other strategies can I adopt to overcome these issues?

推荐答案

如果我对您的理解正确,那么您想使用Visual Studio中的设计"选项卡来查看样式更改并检查WPF应用程序的外观.

If I understand you correctly you want to use your "Design" tab in Visual Studio to see style changes and check the look and feel of your WPF application.

如果是这样,我会让您感到失望,但是我还没有遇到任何WPF开发人员,因此他们使用设计"而不是"XAML"视图在更高级的应用程序中进行更改等.不幸的是,设计"视图有很多缺陷,不能正确显示视图,静态资源转换器存在问题,而且它总是资源匮乏.

If that is the case, I will disappoint you but I haven't met any WPF developer yet using the 'Design' instead of 'XAML' view to make changes etc. in more advanced applications. Unfortunately the "Design" view has many flaws, doesn't display the Views properly, has problem with static resources converter and what is more it is always resource hungry.

我们使用WPF应用程序的方式是构建它们,并使用 Snoop 实用工具来检查问题和更改调查应用程序,绑定错误,样式问题等.我从未见过在设计"视图中使用构建的方式,但没有很多缺陷,hack和性能问题.

The way we are working with WPF applications is building them and inspecting the problems and changes using a Snoop utility to investigate the application, binding errors, style problems, etc. I have never seen a way to use the build in "Design" view without many flaws, hacks and performance issues.

此外,您应该编写一个伪造的主机应用程序,以便无需运行主应用程序即可运行插件(如果这对您来说是个问题)

What is more, you should write a fake host application so that you will be able to run your plugins without the need of running the main app (if that is a problem for you)

这篇关于可插拔应用程序中WPF中的静态资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆