I am developing a WPF application in .NET. I am using many projects because it has some shared files of another project like resource files for localization.
If resx file and xaml file are in the same project (Project1.Properties.Resources.resx), everything works fine (Project1.AccountView.xaml)
Working Tree
|-Project1
| |-Properties
| | |-Resources.resx
| |
| |-AccountView.xaml
|
|
|-Project2
| ...
AccountView.xaml
<UserControl ...
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:p="clr-namespace:Project1.Properties">
....
<TextBox Controls:TextBoxHelper.Watermark="{x:Static p:Resources.Username}"/>
</UserControl>
The problem here is that I have resource files in another project (Project2.Views.Account.Login.resx) and I cannot use these files in AccountView.xaml (Remember that this xaml is inside 'Project1') in the same way as
Working Tree
|-Project1
| |
| |-AccountView.xaml
|
|
|-Project2
|-Views
|-Account
|-Login.resx
AccountView.xaml
<UserControl ...
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:p="clr-namespace:Project2.Views.Account">
...
TextBox Controls:TextBoxHelper.Watermark="{x:Static Login.Username}"/>
</UserControl>
The error when the project has been built is: 'Login' name does not exist in 'clr-namespace:Project2.Views.Account' namespace
All resx files have Public Access Modifier.
Somebody knows how can I solve this problem?
The namespace declaration should include the name of the assembly (project):
xmlns:p="clr-namespace:Project2.Views.Account;assembly=Project2"
...
TextBox Controls:TextBoxHelper.Watermark="{x:Static p:Login.Username}"