English 中文(简体)
混合XAML资源和不同项目的风格
原标题:Trouble merging XAML resources and styles from different project

I am creating a number of WPF applications that all relate around one central WPF application and need to share the same styles and resources. In the first place I created a folder in my main project and added some XAML styles which all worked in displaying UI in the styles I wanted. Later, I created another application but wanted to share the same styles so I moved the styles into a third project, added that project to the main application and added the reference to the styles project. The problem is that the will not recognise my styles project. I prefixed the style with the project name and that did not work at all.

我现在要谈谈我可以进入资源开发商“路径”部分的xaml文档的整个相对途径以及该工程。 然而,如果我把该项目转移到另一个方面,那就会失败。 我恳请大家问,我为什么会这样做,有原因,例如简单地重新调整我的项目结构。 因此,通过参考而不是档案处理资源比较容易。

我知道答案是暗淡的,但我无法找到另一个项目的风格。

迄今为止,我从这个网站获得了很大的反馈,将非常感谢任何帮助。

最佳回答

OK,我把它sus了! 基本上,你在单独的项目中增加一套资源字典,然后把该项目添加到解决方案中,并在你的主要项目中提及该项目。 我很想到这一点,但需要参考我的资源用于我的主要项目。

我尝试使用全方位的路标,但当他工作时,这不是一个很好的解决办法,因为如果我移动项目,重新连接项目,档案就会因为无效。

The syntax I used that work is as follows:

<ResourceDictionary Source="/StyleResource;component/MSResources/TabControl.xaml" />

Where StyleResources is the name of my project that holds my shared styles, MSResources is the folder in the styles project that holds the xaml file and the file name at the end is obvious. I have not yet read up about the “component” reference but it works so I will look at it later and update this post.

问题回答

暂无回答




相关问题
Creating a Style in code behind

Does anyone know how to create a wpf Style in code behind, I can t find anything on the web or MSDN docs. I have tried this but it is not working: Style s = new Style(typeof(TextBlock)); s....

WPF Custom Themes

I have a simple question which is giving me some difficulty. I have downloaded a custom them for WPF of the net. Now i want to apply this theme to my App instead of the default one. How do i do that,...

Is it sometimes bad to use <BR />?

Is it sometimes bad to use <BR/> tags? I ask because some of the first advice my development team gave me was this: Don t use <BR/> ; instead, use styles. But why? Are there negative ...

WPF - How to apply effect to a cropped image?

I have an Image being clipped like so: <Image Width="45" Grid.Column="0" Source="{Binding Photo}"> <Image.Clip> <RectangleGeometry Rect="0,0,45,55" RadiusX="8" RadiusY="8" /...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签