XAML中带有撇号的StringFormat绑定不起作用 [英] StringFormat Binding with Apostrophe in XAML Not Working
本文介绍了XAML中带有撇号的StringFormat绑定不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Silverlight 4中工作,我试图在与TextBlock绑定的值中插入撇号:
I'm working in Silverlight 4 and I'm trying to insert an apostrophe in a value that is bound to a TextBlock:
<TextBlock Text="{Binding MyValue, StringFormat='The value is '{0}''}"/>
但是,即使我尝试使用<$ c进行转义,我也得到XAML分析错误。 $ c> \'和&
都没有成功。
However, I'm getting XAML parse errors even though I have tried escaping with it with \'
and "
to no success.
推荐答案
这将在WPF或Silverlight中工作。
This will work in WPF or Silverlight.
<Grid>
<Grid.Resources>
<system:String x:Key="Format">The value is '{0}'</system:String>
</Grid.Resources>
<TextBlock Text="{Binding MyValue, StringFormat={StaticResource Format}}"/>
</Grid>
这篇关于XAML中带有撇号的StringFormat绑定不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文