此特定于 Android 平台的功能控制打开 SwipeView 时使用的转换。 其使用方式是在 XAML 中将 SwipeView.SwipeTransitionMode 可绑定属性设置为 SwipeTransitionMode 枚举的值:
<ContentPage ...
             xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" >
    <StackLayout>
        <SwipeView android:SwipeView.SwipeTransitionMode="Drag">
            <SwipeView.LeftItems>
                <SwipeItems>
                    <SwipeItem Text="Delete"
                               IconImageSource="delete.png"
                               BackgroundColor="LightPink"
                               Invoked="OnDeleteSwipeItemInvoked" />
                </SwipeItems>
            </SwipeView.LeftItems>
            <!-- Content -->
        </SwipeView>
    </StackLayout>
</ContentPage>
或者,可以使用 Fluent API 从 C# 使用它:
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
...
SwipeView swipeView = new Xamarin.Forms.SwipeView();
swipeView.On<Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag);
// ...
SwipeView.On<Android> 方法指定这一平台特定功能仅可在 Android 上运行。 Xamarin.Forms.PlatformConfiguration.iOSSpecific 命名空间中的 SwipeView.SetSwipeTransitionMode 方法用于控制打开 SwipeView 时使用的过渡。 SwipeTransitionMode 枚举提供了两种可能的值:
- Reveal表示轻扫项目将在轻扫- SwipeView内容时显示,并且是- SwipeView.SwipeTransitionMode属性的默认值。
- Drag表示在轻扫- SwipeView内容时,轻扫项目将被拖入视图。
此外,SwipeView.GetSwipeTransitionMode 方法还可用于返回应用于 SwipeTransitionMode 的 SwipeView。
结果是指定的 SwipeTransitionMode 值被应用到 SwipeView 中,从而控制打开 SwipeView 时使用的转换:
