我正在尝试使用StringFormat在一个绑定到TextBlock的值周围插入叛逆(撇号?):
<TextBlock Text="{Binding MyValue, StringFormat='The value is '{0}''}"/>
Run Code Online (Sandbox Code Playgroud)
但是,我得到一个编译错误:
MarkupExtension中的名称和值不能包含引号.MarkupExtension参数'MyValue,StringFormat ='值为'{0}''}'无效.
我注意到它确实适用于引号:
<TextBlock Text="{Binding MyValue, StringFormat='The value is "{0}"'}"/>
Run Code Online (Sandbox Code Playgroud)
这是StringFormat的错误吗?
我有一个带边框的WPF项目使用以下样式.计划是当鼠标移过边界时使发光效果淡入淡出,并在离开时淡出淡出效果.
<Style x:Key="BorderGlow" TargetType="Border">
<Style.Resources>
<Storyboard x:Key="GlowOn">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(DropShadowEffect.Opacity)">
<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="GlowOff">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(DropShadowEffect.Opacity)">
<SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Style.Resources>
<Setter Property="CornerRadius" Value="6,1,6,1" />
<Setter Property="BorderBrush" Value="{StaticResource SelectedBorder}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Background" Value="{StaticResource DeselectedBackground}" />
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
<Setter Property="TextBlock.Foreground" Value="{StaticResource SelectedForeground}" />
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="90"/>
</Setter.Value>
</Setter>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect ShadowDepth="0" BlurRadius="8" Color="#FFB0E9EF"/>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource GlowOn}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard …
Run Code Online (Sandbox Code Playgroud)