我有AlternationCount設置爲2。我目前設定的ListViewItem的背景色交替的顏色ListViewItem的風格的ListView,我想補充一個不觸發這將觸發ColorAnimation第三觸發動畫紅色和白色的顏色,當綁定視圖模型的屬性爲true(在這種情況下,所謂的財產「鎖定」)。ColorAnimation在MultiDataTrigger的EnterActions當項目被添加到ListView控件
我遇到了這個帖子,並試圖在XAML底部:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/e7897cbd-71d9-45e6-9b17-0cd5bde5859f
但是,動畫不會出現過度觸發我,直到我的鼠標或選擇項目,然後選擇或將鼠標懸停在不同的項目上。我從前兩個MultiDataTriggers中獲取交替的顏色,但是當項目添加到集合中時不會觸發動畫。這是我的XAML:
<Style x:Key="alternatingListViewItemStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="Background" Value="White" />
<Style.Triggers>
<MultiDataTrigger >
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(ItemsControl.AlternationIndex)}" Value="0" />
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(ListViewItem.IsSelected)}" Value="False" />
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Panel.IsMouseOver)}" Value="False" />
<Condition Binding="{Binding Locked}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="DarkGray" />
</MultiDataTrigger>
<MultiDataTrigger >
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(ItemsControl.AlternationIndex)}" Value="1" />
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(ListViewItem.IsSelected)}" Value="False" />
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Panel.IsMouseOver)}" Value="False" />
<Condition Binding="{Binding Locked}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="SlateGray" />
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(ListViewItem.IsSelected)}"
Value="False" />
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Panel.IsMouseOver)}"
Value="False" />
<Condition Binding="{Binding Locked}"
Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetProperty="(Control.Background).(SolidColorBrush.Color)"
From="Red" To="White" Duration="0:0:0.2"
AutoReverse="True" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
</Style.Triggers>
</Style>