无法在 ContentStringFormat 中使用 {0} 作为第一个字符
Unable to use {0} in ContentStringFormat as the first character
我想在Label Content中动态插入值,通过ContentStringFormat很容易解决,f.e。 :
<Label
Content="{Binding ElementName=recipesDataGrid, Path=Items.Count}"
ContentStringFormat="recipe(s) found: {0}"/>
但是当我想将 {0} 放在 ContentStringFormat 的开头时,我收到错误消息:
您必须 escape the curly braces 和 {}
,否则它们将被解释为标记扩展。
Provides the XAML escape sequence for attribute values. The escape sequence allows the subsequent values in the attribute to be interpreted as a literal.
通过在开头添加 {}
来调整您的内容格式字符串。
<Label Content="{Binding ElementName=recipesDataGrid, Path=Items.Count}"
ContentStringFormat="{}{0} recipe(s) found" />
我想在Label Content中动态插入值,通过ContentStringFormat很容易解决,f.e。 :
<Label
Content="{Binding ElementName=recipesDataGrid, Path=Items.Count}"
ContentStringFormat="recipe(s) found: {0}"/>
但是当我想将 {0} 放在 ContentStringFormat 的开头时,我收到错误消息:
您必须 escape the curly braces 和 {}
,否则它们将被解释为标记扩展。
Provides the XAML escape sequence for attribute values. The escape sequence allows the subsequent values in the attribute to be interpreted as a literal.
通过在开头添加 {}
来调整您的内容格式字符串。
<Label Content="{Binding ElementName=recipesDataGrid, Path=Items.Count}"
ContentStringFormat="{}{0} recipe(s) found" />