【发布时间】:2011-10-31 05:45:20
【问题描述】:
我正在尝试使用 StringFormat 在绑定到 TextBlock 的值周围插入撇号(撇号?):
<TextBlock Text="{Binding MyValue, StringFormat='The value is '{0}''}"/>
但是,我得到一个编译错误:
MarkupExtension 中的名称和值不能包含引号。 MarkupExtension 参数 'MyValue, StringFormat='The value is '{0}''}' 无效。
我确实注意到它确实适用于引号:
<TextBlock Text="{Binding MyValue, StringFormat='The value is "{0}"'}"/>
这是 StringFormat 的错误吗?
【问题讨论】:
标签: c# wpf escaping apostrophe string-formatting