如何删除ListView的添加项动画? [英] How to remove ListView's add item animation?
问题描述
我有一个ListView
,我编辑了它的ItemContainerStyle
以修改某些样式,但是我不知道如何在添加项目时删除该烦人的动画.
I have a ListView
and I edited its ItemContainerStyle
to modify some style but I don't know how to remove that annoying animation when you add an item.
使用ItemsControl
,当您添加新项目时,它会立即显示,没有任何动画.
With an ItemsControl
, when you add a new item, it appears instantly, without any animation.
使用ListView
,该项目需要一段时间,然后开始显示动画.
With ListView
, the item takes a while and then, it starts an animation to show up.
我只想删除该add animation
,当我单击Add item
时,它会立即显示,没有多余的东西.
I just want to remove that add animation
and when I click on Add item
it appears instantly, no extra stuff.
我认为它应该属于ItemContainerStyle
,但是即使我注释掉了所有视觉状态动画,并且仍然存在.我错过了一些东西.
I think that it should belong to ItemContainerStyle
but even I commented out all visualstate animations and is still there. I'm missing something out.
推荐答案
这些动画称为过渡,它们是ListViewStyle
的一部分.要更改它,请在设计器中的ListView
控件上单击鼠标右键,然后选择Edit Template
> Edit a Copy...
.这会将内置样式添加到您的XAML中.
These animations are called transitions and they are part of ListViewStyle
. To change it right click on ListView
control in the designer and select Edit Template
> Edit a Copy...
. This will add the built-in style to your XAML.
样式的以下部分对您很感兴趣:
The following part of the style is of interest to you:
<Setter Property="ItemContainerTransitions">
<Setter.Value>
<TransitionCollection>
<AddDeleteThemeTransition/>
<ContentThemeTransition/>
<ReorderThemeTransition/>
<EntranceThemeTransition IsStaggeringEnabled="False"/>
</TransitionCollection>
</Setter.Value>
</Setter>
我不确定您到底不喜欢哪个动画,但是请尝试从TransitionCollection
中删除AddDeleteThemeTransition
和/或EntranceThemeTransition
.它应该可以解决问题.
I'm not sure which animation exactly you dislike but try removing AddDeleteThemeTransition
and/or EntranceThemeTransition
from TransitionCollection
. It should do the trick.
别忘了确保将修改后的样式应用于所需的ListView
.
Don't forget to make sure the modified style is applied to the desired ListView
.
这篇关于如何删除ListView的添加项动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!