2012-07-17 31 views
0

试图对DevExpress网格中的单个行执行简单的红色闪烁效果。如何使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”动画对象不能用于动画属性'背景',因为它是不兼容的类型'System.Windows.Media.Brush'。

也试过改变Storyboard.TargetPropertyBackground.Color并获得:

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

我该如何解决这个问题?

回答

1

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

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

我猜背景是空的,所以故事板无法找到动画的东西。

0

尝试

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

为我工作。

+0

不会为我工作 - 我猜问题是空值。 – 2012-07-17 10:24:51

+0

还是一样的例外? – Zak 2012-07-17 10:25:23

+0

非常相似,在异常消息中带有“Background。(0)”。 – 2012-07-17 10:26:09

0

你可以打开一个新的线程。在这个线程中你使用一个循环。在这个循环中,您可以更改该行的背景颜色。在循环中,你睡了0.3秒或其他东西。所以它应该看起来像闪烁。

问候