Android の SwipeView スワイプ画面切り替えモード

サンプルのダウンロードサンプルのダウンロード

この Android プラットフォーム固有のコントロールは、 を開くときに使用される遷移を SwipeView制御します。 バインド可能なプロパティを列挙の値SwipeTransitionModeSwipeView.SwipeTransitionMode設定することで、XAML で使用されます。

<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 でのみ実行されるように指定します。 名前空間の メソッドは SwipeView.SetSwipeTransitionMode 、 を Xamarin.Forms.PlatformConfiguration.iOSSpecific 開くときに使用される遷移を SwipeView制御するために使用されます。 列挙には SwipeTransitionMode 、次の 2 つの値が用意されています。

  • Reveal は、コンテンツがスワイプされるとスワイプ項目が表示 SwipeView されることを示し、プロパティの SwipeView.SwipeTransitionMode 既定値です。
  • Drag は、コンテンツがスワイプされると、スワイプ項目がビュー SwipeView にドラッグされることを示します。

さらに、 メソッドを SwipeView.GetSwipeTransitionMode 使用して、 SwipeTransitionMode に適用 SwipeViewされる を返すことができます。

結果は、指定した SwipeTransitionMode 値が に適用され、 SwipeViewを開くときに使用される遷移を SwipeView制御します。

SwipeView SwipeTransitionModes