当我将项目添加到listView中时,有一些默认动画花费大约1秒钟才能完成动画中的淡出。有没有一种方法可以减少它或根本不使用它,以便您可以立即获得填充的listView?
ListView
项目集合时是否禁用行动画。它是通过将可约束属性设置为false的XAML消耗的:
ListView.RowAnimationsEnabled
在线,可以使用Fluent API从C#消耗它:
<ContentPage ...
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls">
<StackLayout>
<ListView ... ios:ListView.RowAnimationsEnabled="false">
...
</ListView>
</StackLayout>
</ContentPage>
有关更多信息,请检查文档:ios
listViewRow Animations。对于Windows(Winui),我使用了一个自定义处理程序/渲染器,您可以在下面看到:
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
...
listView.On<iOS>().SetRowAnimationsEnabled(false);
我认为您看到的淡入淡出与使用.add()将项目加载到可观察的集合中有关,并且一次被渲染。 try ItemCollection =新的ObservableCollection(所有要加载的项目)
这将同时渲染所有项目。