Question

I am beginning to study the "Visual Studio way of doing stuff", and created a WPF sandbox project.

I know for sure that my company wants to reuse the same UI theming for multiple projects.

So I created this one application project, and want to create another project to contain the UI theming and styling files. As an example, I'd name it "CompanywideThemingProject".

Visual Studio offers me lots of project templates, such as "WPF Application", "Class Library", "Console Application", and so on. All I want to do is to create some XAML dictionaries, and possibly some .cs files with some helper functions for color manipulation, but I doubt this could be considered a "WPF Application". The Class Library description doesn't seem to apply also, because I don't want to create .dll files (or at least I think I don't).

The goal would be to have one centralized, versioned Visual Studio project which I could "import" in more than one Visual Studio solution for different applications, so that I can be sure the visual styling of all applications is consistent.

Any idea how I should structure the VS projects/solutions?

Thanks for reading!

Was it helpful?

Solution

I usually create a Class Library which will contain everything I need:

  • Custom controls
  • Resource Dictionaries
  • Various resources such as pictures
  • Custom .cs files (custom converters for example)

Beware that for some reason, Visual Studio 2010 won't propose you to add a ResourceDictionary in a class library.

To be honest I absolutely don't know why it won't ask me to add it, but I ended up using a workaround: Either:

  • manually create the .xaml file and then reference it to Visual Studio
  • create a WPF user control, then remove the .xaml.cs file and use the xaml as a ResourceDictionary

That's all for me, and it works perfectly for having a centralized project containing common controls/UI material

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top