0
我有一個datagrid,其中包含一個datatrigger,當viewmodel中的值發生更改時,該datagrid會觸發行動畫。這有效,但當行進入視口時也會觸發它。所以,當我排序(通過點擊列標題),篩選或滾動,行動畫發生。不要在排序上觸發DataTrigger
如何才能讓動畫只在viewmodel中的值發生變化時觸發?
<DataGrid IsReadOnly="True" x:Name="Cards">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Obtained}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" From="#C8E6C9" Duration="0:0:3"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding Obtained}"/>
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
<!-- etc... -->
</DataGrid.Columns>
</DataGrid>
我不知道這是否重要,但網格綁定到ReactiveUI IReactiveDerivedList
有ReactiveList
作爲源。
背後,你試過'SuppressChangeNotifications'?看看[ReactiveUI的好東西](https://janhannemann.wordpress.com/2016/10/06/reactiveui-goodies-reactivelist/) –
嗯,也許我誤解了'SuppressChangeNotifications'的作用,但我不'沒有任何問題與我的viewmodel更新我的觀點。例如,當我點擊網格中的標題來對網格進行排序時,我的問題就會出現。 – Chris
你的意思是ReactiveUI處理排序? (我自己沒有用過)。如果答案是肯定的,那麼也許你應該重寫那個行爲,在你的代碼中處理排序並且不會引發任何事件。 –