Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all!

Here is my problem:

Initially, I only had a project (MainProject) with a global ResourceDictionary (StyleResources), classes, etc. The project was growing, and I decided to separate the resources into new project (SecondaryProject).

First question: What project type should be SecondaryProject if it only contains ResourcesDictionaries? This project must have MainWindow.xaml, App.xaml... files?

Continuing with the explanation...
In one of the initial styles (TabItemStyle) I used a converter that it was define in a namespace "Converter" with a class named TabSizeConverter and using next code I get it to work. This was the code including at inicial StyleResources file:

- xmlns:local="clr-namespace:Converters"
- <local:tabsizeconverter x:key="tabSizeConverter" />

Second question:Now, with my new configuration, how to get it working again? I am having an error because It can´t find TabSizeConverter class and it can´t crete this type.

Thanks and regards:
Posted
Updated 29-Aug-13 21:29pm
v3

1 solution

Hi Torin86,
If i understood your question correctly, you can try below mentioned.

Step 1: Right click on the current solution and Select Add New Project -> WPF Application. (This can have the Main.xaml and resource files).
Step 2: In the Newly created project, Right click then select "Properties". Select Application and then change the Output type to "Class Library".
Step 3. Build the newly created project which will create .dll file.
Step 4. In the Main Project click on Reference and add this new project .dll file as project reference.
Step 5. In the Main project .xaml file use the pack assmebly to refer the styles and converter present in the new project.

XML
<ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/NewprojectName;component/StyleXamlfileName.xaml"/>
            </ResourceDictionary.MergedDictionaries>
<ResourceDictionary>


Step 6. Build and check it should work fine.



Hope I help you.

Thanks
Sriram.B
 
Share this answer
 
Comments
torin86 30-Aug-13 6:36am    
First of all thanks for ask my question so quickly!

I´m trying to do what you are saying and now I´ve two questions:

1. The namespace wuith the converter must to be in Main or in Secondary Project? If I don´t put it into Secondary project I can´t use it, can I?
2. When I generate the Secondary project, I am having an error because as now is a ClassLibrary Project, it can´t find the ApplicationDefinition element.

What do you think I have to try now?

Thanks.
Sriram Bala 30-Aug-13 7:21am    
Welcome. here goes my suggestions.
1. Yes you need to add the namespace in the .xaml file of the main project
xmlns:vc="clr-namespace:ValueConverters;assembly=SecondaryProjectname" You can use intellisence functionality to select the correct namespace.

2. Please dont create classlibrary project. Create a normal WPF application project, then select the properties and change the output type to class library. this will solve your problem.
Thanks
Sriram.B

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900