我正在用.NET开发一个WPF应用程序,我使用许多项目,因为它有其他项目的一些共享文件,比如用于本地化的资源文件。
如果resx文件和xaml文件位于同一个项目(Project1.Properties.Resources.resx)中,则一切正常(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>这里的问题是,我在另一个项目(Project2.Views.Account.Login.resx)中有资源文件,我不能在AccountView.xaml中使用这些文件(请记住,这个xaml在‘Project1’中)的方式与
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>生成项目时的错误是:“clr-命名空间:Project2.Views.Account”命名空间中不存在“登录”名称
所有resx文件都有公共访问修饰符。
有人知道我该怎么解决这个问题吗?
发布于 2018-11-07 12:41:55
命名空间声明应该包括程序集(项目)的名称:
xmlns:p="clr-namespace:Project2.Views.Account;assembly=Project2"
...
TextBox Controls:TextBoxHelper.Watermark="{x:Static p:Login.Username}"https://stackoverflow.com/questions/53186836
复制相似问题