我有一个数据集,行的颜色是由一个级别参数决定的,我在行样式中进行转换。这很好,但现在我也希望在我用鼠标进入行时临时更改颜色,并拖放(在离开或删除时更改)。我设法用以下代码更改颜色:
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource MyDataGridRowStyle}">
<Setter Property="Background" Value="{Binding Level,Converter={StaticResource LevelToIndentConverter}}" />
<Style.Triggers>
<EventTrigger RoutedEvent="DataGridRow.DragEnter">
<BeginStoryboard x:Name="DragHoverStoryboard">
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color"
Duration="0:0:0" To="#41B1E1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="DataGridRow.DragLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="Background.Color"
Duration="0:0:0" To="Transparent" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>问题是回到原来的颜色。目前,我必须在DragLeave事件触发器中作为透明的,但我希望它是我的“旧”颜色。
我试着做一个简单的绑定(和我的setter一样),但是我得到了异常,并且看到你不能绑定颜色动画。那么,还有什么东西我可以用或避开这个问题吗?总之,我只想这样做:
发布于 2016-04-29 22:45:33
然后将其添加到动画中,并移除第二个动画。
FillBehavior="Stop"https://stackoverflow.com/questions/36948534
复制相似问题