【发布时间】: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