【问题标题】:Color animation on Grid Control Row using Storyboard使用情节提要的网格控制行上的彩色动画
【发布时间】:2014-09-10 17:54:09
【问题描述】:

我正在使用第三方网格控件。当 MVVM 属性值更改为“成功”时,我想将行颜色从常规背景设置为浅绿色

我有以下代码

<dxg:GridControl.RowStyle>
    <Style TargetType="{x:Type dxg:GridRowContent}" >
        <Style.Triggers>
            <DataTrigger Binding="{Binding RowData.Row.State}" Value="Success">
                <DataTrigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <ColorAnimation Storyboard.Target="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                            Storyboard.TargetProperty="Background" 
                                            From="White" To="LightGreen" Duration="0:0:5" />
                        </Storyboard>
                    </BeginStoryboard>
                </DataTrigger.EnterActions>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</dxg:GridControl.RowStyle>

我收到以下错误

System.Windows.Data 错误:2:找不到目标元素的管理 FrameworkElement 或 FrameworkContentElement。 BindingExpression:(无路径);数据项=空;目标元素是“ColorAnimation”(HashCode=47149397);目标属性是“目标”(类型“依赖对象”)

我必须以某种方式为 Storyboard 的 Target 获取类型为 dxg:GridRowContent 的对象的引用。 Mode=FindAncestor 也没有找到。

有什么线索吗?

【问题讨论】:

  • 您是否尝试完全跳过Target 并将TargetProperty 更改为Backgorund.Color
  • @dkozl 请发表您的评论作为答案。它奏效了。
  • 当然,answer 已添加

标签: wpf


【解决方案1】:

您不需要将Storyboard.Target 设置为默认情况下它应该应用于您的行并将Storyboard.TargetProperty 更改为Background.Color 因为这是ColorAnimationBackgroundBrush

<ColorAnimation 
    Storyboard.TargetProperty="Background.Color"
    From="White" 
    To="LightGreen" 
    Duration="0:0:5" />

【讨论】:

    猜你喜欢
    • 2021-01-26
    • 1970-01-01
    • 1970-01-01
    • 2014-02-08
    • 1970-01-01
    • 2010-10-16
    • 2015-02-14
    • 2014-06-16
    • 1970-01-01
    相关资源
    最近更新 更多