【问题标题】:Unable to resolve property '%1' while processing properties for Uid '%0'处理 Uid '%0' 的属性时无法解析属性 '%1'
【发布时间】:2015-06-10 16:42:47
【问题描述】:

我正在尝试本地化我的 WP 8.1 应用程序。

这里是Strings/en-us/Resources.resw的一部分:

<data name="SampleProperty.Text" xml:space="preserve">
    <value>Sample text</value>
</data>
<data name="SampleProperty.SomeRandomKey" xml:space="preserve">
    <value>SAMPLE TEXT</value>
</data>

还有一个应用程序页面包含以下代码:

<TextBlock x:Uid="SampleProperty" />

但应用在导航到该页面的过程中抛出异常:

WinRT information: Unable to resolve property '%1' while processing properties for Uid '%0'. [Line: 167 Position: 24]
Additional information: The text associated with this error code could not be found.

如果我从资源字典中删除SampleProperty.SomeRandomKey,那么一切正常。但是这个字符串在我的应用程序的另一部分中使用。

问题可能出在哪里?

UPD

我在the documentation 的示例中添加了类似的属性:

<data name="SampleProperty.Text" xml:space="preserve">
    <value>Sample text</value>
</data>
<data name="SampleProperty.Width" xml:space="preserve">
    <value>0</value>
</data>

一切正常。 但我不明白为什么这行得通,为什么第一种情况会出现异常......

【问题讨论】:

    标签: c# windows-runtime windows-store-apps windows-phone-8.1 windows-8.1


    【解决方案1】:

    尚不清楚您的示例中的“SomeRandomKey”是什么,以及您试图用它实现什么。 但是抛出这个异常是因为 TextBlocks 没有 SomeRandomKey 属性。 它们有文本、宽度,但绝对不是“SomeRandomKey”。只需将其删除。

    【讨论】:

    • 文档没有提供明确的信息,即对于字符串资源,点之后提供的所有键(文本、宽度等)必须在控件端具有相应的属性,否则将引发异常。这并不明显。所以我想你回答我的问题。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    • 2014-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多