我试图在TextBox中显示参考资料中的一些文本。在我的Properties.Resources中,我有一个名为DefaultUrl的字符串资源。
我使用以下代码在TextBox中显示它:
<Window x:Class="........"
...
...
xmlns:properties="clr-namespace:project_name.Properties">
<TextBox Text="{x:Static properties:Resources.DefaultUrl}"/>
</Window>在构建项目时,它正确地显示了TextBox中的资源值,但是在运行项目时,它会给出以下错误:
抛出的
异常: System.Xaml.dll异常中的“System.ArgumentException”:System.Xaml.dll异常中的“System.Xaml.XamlObjectWriterException”:PresentationFramework.dll中的“System.Windows.Markup.XamlParseException”
“为'System.Windows.Markup.StaticExtension‘提供一个例外。”行号'725‘和线位置'149’。
如何在XAML中显示Properties.Resources字符串??
发布于 2019-11-18 07:39:40
解决方案:
通过使用@Max和@Styx注释,我能够通过将访问修饰符下拉(在项目资源中)值从Internal更改为Public来解决这个问题
https://stackoverflow.com/questions/58909471
复制相似问题