ListView Row Animationen unter iOS

Beispiel herunterladen Das Beispiel herunterladen

Diese plattformspezifische iOS-Plattform steuert, ob Zeilenanimationen deaktiviert werden, wenn die ListView Elementsammlung aktualisiert wird. Es wird in XAML verwendet, indem die ListView.RowAnimationsEnabled bindbare Eigenschaft auf falsefestgelegt wird:

<ContentPage ...
             xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core">
    <StackLayout Margin="20">
        <ListView ... ios:ListView.RowAnimationsEnabled="false">
            ...
        </ListView>
    </StackLayout>
</ContentPage>

Alternativ kann sie über C# mit der Fluent-API genutzt werden:

using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
...

listView.On<iOS>().SetRowAnimationsEnabled(false);

Die ListView.On<iOS> -Methode gibt an, dass diese plattformspezifische Nur unter iOS ausgeführt wird. Die ListView.SetRowAnimationsEnabled -Methode im Xamarin.Forms.PlatformConfiguration.iOSSpecific Namespace wird verwendet, um zu steuern, ob Zeilenanimationen deaktiviert werden, wenn die ListView Elementsammlung aktualisiert wird. Darüber hinaus kann die ListView.GetRowAnimationsEnabled -Methode verwendet werden, um zurückzugeben, ob Zeilenanimationen für ListViewdeaktiviert sind.

Hinweis

ListView Zeilenanimationen sind standardmäßig aktiviert. Daher tritt eine Animation auf, wenn eine neue Zeile in eine ListVieweingefügt wird.