处理Uid'%0'

时间:2015-06-08 17:51:42

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

我正在尝试本地化我的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>

一切正常。 但是我无法理解为什么这会起作用以及为什么第一种情况会给出例外......

1 个答案:

答案 0 :(得分:2)

目前还不清楚你的例子中有哪些“SomeRandomKey”,以及你想用它实现的目标。 但抛出此异常是因为TextBlocks没有SomeRandomKey属性。 它们有Text,Width,但绝对不是“SomeRandomKey”。只需删除它。