【问题标题】:How to make a DevExpress grid row blink?如何使 DevExpress 网格行闪烁?
【发布时间】:2012-07-16 05:52:23
【问题描述】:

尝试对 DevExpress 网格中的单行执行简单的红色闪烁效果。

我在网格的行上应用了以下样式:

<Style x:Key="AlertedRowStyle" TargetType="{x:Type dxg:GridRowContent}">
    <Style.Triggers>
        <DataTrigger Binding="{Binding Path=Row.IsAlerted}" Value="False">
            <DataTrigger.EnterActions>
                <BeginStoryboard>
                    <Storyboard>
                        <ColorAnimation
                                    Storyboard.TargetProperty="Background"
                                    To="Red"
                                    Duration="0:0:0.500"
                                    AutoReverse="True"
                                    RepeatBehavior="Forever">
                            <ColorAnimation.EasingFunction>
                                <CircleEase EasingMode="EaseOut" />
                            </ColorAnimation.EasingFunction>
                        </ColorAnimation>
                    </Storyboard>
                </BeginStoryboard>
            </DataTrigger.EnterActions>
            <DataTrigger.ExitActions>
                <BeginStoryboard>
                    <Storyboard>
                        <ColorAnimation
                                    Storyboard.TargetProperty="Background"
                                    To="White"
                                    Duration="0:0:0.500" />
                    </Storyboard>
                </BeginStoryboard>
            </DataTrigger.ExitActions>
        </DataTrigger>
    </Style.Triggers>
</Style>

它会导致以下异常:

“System.Windows.Media.Animation.ColorAnimation”动画对象不能用于动画属性“Background”,因为它的类型“System.Windows.Media.Brush”不兼容。

还尝试将Storyboard.TargetProperty更改为Background.Color并得到:

无法解析属性路径“Background.Color”中的所有属性引用。验证适用的对象是否支持这些属性。

我该如何解决这个问题?

【问题讨论】:

    标签: wpf devexpress


    【解决方案1】:

    Storyboard.TargetProperty="Background.Color" 是对的。试试

    <Style x:Key="AlertedRowStyle" TargetType="{x:Type dxg:GridRowContent}">
        <Setter Property="Background" Value="Transparent" />
        <Style.Triggers>
            ...
    

    我猜背景是空的,所以情节提要找不到动画的东西。

    【讨论】:

      【解决方案2】:

      试试

      Storyboard.TargetProperty="Background.(SolidColorBrush.Color)"
      

      为我工作。

      【讨论】:

      • 对我不起作用 - 我猜问题是空值。
      • 非常相似,在异常信息中有Background.(0)
      【解决方案3】:

      您可以打开一个新线程。在此线程中,您使用循环。在此循环中,您可以更改行的背景颜色。在循环中,您将线程休眠 0.3 秒或其他时间。所以它应该看起来像在闪烁。

      问候

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-02
        • 2018-01-30
        • 1970-01-01
        相关资源
        最近更新 更多