小编Zod*_*man的帖子

不能在XAML绑定的StringFormat中使用撇号?

我正在尝试使用StringFormat在一个绑定到TextBlock的值周围插入叛逆(撇号?):

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

但是,我得到一个编译错误:

MarkupExtension中的名称和值不能包含引号.MarkupExtension参数'MyValue,StringFormat ='值为'{0}''}'无效.

我注意到它确实适用于引号:

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

这是StringFormat的错误吗?

c# wpf escaping string-formatting apostrophe

12
推荐指数
2
解决办法
7910
查看次数

如何设置DropShadowEffect的不透明度?

我有一个带边框的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)

wpf animation effects opacity storyboard

6
推荐指数
1
解决办法
1万
查看次数