我在项目StringResources
中有一个资源文件(名为xyz.mvvm.res
)
(res是一个文件夹)。
<Window x:Class="xyz.MVVM.Views.ReadAllReportWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"
xmlns:resources="clr-namespace:xyz.MVVM.res;assembly=xyz.MVVM"
Title="{x:Static resources:StringResources.Window_Title}"
WindowStartupLocation="CenterScreen">
<Grid>
</Grid>
</Window>
我收到错误
“名称空间”中没有名称“StringResources” “CLR-名称空间:xyz.MVVM.res;装配= xyz.MVVM”
资源文件设置为public! 我很绝望..
编辑: StringResources.Designer.cs:
namespace xyz.MVVM.res {
using System;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class StringResources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal StringResources() {
}
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TimeRecordReader.MVVM.res.StringResources", typeof(StringResources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
public static string Window_Title {
get {
return ResourceManager.GetString("Window_Title", resourceCulture);
}
}
}
}
答案 0 :(得分:1)
<Window x:Class="xyz.MVVM.Views.ReadAllReportWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"
xmlns:resources="clr-namespace:xyz.MVVM.res;assembly=xyz.MVVM"
WindowStartupLocation="CenterScreen">
<Window.Title>
<Binding Source="{x:Static resources:StringResources.Window_Title}"/>
</Window.Title>
<Grid>
</Grid>
</Window>
答案 1 :(得分:0)
我遇到了类似的问题,但事实证明我必须删除缓存。
- 保存并关闭MS Visual Studio
- 转到%LOCALAPPDATA%\ Microsoft \ VisualStudio \ 14.0 \ Designer \ ShadowCache \
- 删除内容
-Open MS Visual Studio
注意:输入您的版本号而不是14.0