我正在尝试绑定在 Resources.resx 中定义的名为 title 的静态字符串。当我运行应用程序时,出现以下错误。
在调查此站点上的错误后,我发现生成的 Resources 类被标记为内部并且 WPF 正在尝试从另一个程序集中解析资源,因此在您的资源被标记为公共之前它不会成功。同样,我有一个项目,其中包含我定义的视图和资源。
我不需要任何朋友集会。我相信可以在同一个程序集中访问内部类。我发现一位用户的类似帖子,他建议使用 ResXFileCodeGenerator。你对此有何看法?
System.Windows.Markup.XamlParseException occurred
HResult=-2146233087
Message='Provide value on 'System.Windows.Markup.StaticExtension' threw an exception.' Line number '11' and line position '9'.
Source=PresentationFramework
LineNumber=11
LinePosition=9
StackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at TestApp.MainWindow.InitializeComponent() in ~\TestApp\TestApp\MainWindow.xaml:line 1
at TestApp.MainWindow..ctor() in ~\TestApp\TestApp\MainWindow.xaml.cs:line 28
InnerException: System.ArgumentException
HResult=-2147024809
Message='TestApp.Properties.Resources.Firstname' StaticExtension value cannot be resolved to an enumeration, static field, or static property.
Source=System.Xaml
StackTrace:
at System.Windows.Markup.StaticExtension.ProvideValue(IServiceProvider serviceProvider)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
InnerException: