在XAML中使用Apostrophe进行StringFormat绑定不起作用

Sue*_*zio 3 data-binding silverlight wpf xaml string-formatting

我在Silverlight 4中工作,我试图在一个绑定到TextBlock的值中插入一个撇号:

<TextBlock Text="{Binding MyValue, StringFormat='The value is &apos;{0}&apos;'}"/>
Run Code Online (Sandbox Code Playgroud)

但是,即使我尝试使用它\'并且&quot;没有成功,我也会收到XAML解析错误.

Mar*_*tin 7

这将在WPF或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>
Run Code Online (Sandbox Code Playgroud)