■ SwipeView 클래스의 On<T> 메소드를 사용해 스와이프 전환 모드를 설정하는 방법을 보여준다. (ANDROID)
▶ MainPage.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<?xml version="1.0" encoding="utf-8" ?> <ContentPage x:Class="TestProject.MainPage" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> <SwipeView x:Name="swipeView"> <SwipeView.LeftItems> <SwipeItems> <SwipeItem BackgroundColor="LightGreen" Text="즐겨찾기" Invoked="favoriteSwipeItem_Invoked"> <SwipeItem.IconImageSource> <FontImageSource FontFamily="ionicons" Size="48" Color="Red" Glyph="" /> </SwipeItem.IconImageSource> </SwipeItem> <SwipeItem BackgroundColor="LightPink" Text="삭제" Invoked="deleteSwipeItem_Invoked"> <SwipeItem.IconImageSource> <FontImageSource FontFamily="ionicons" Size="48" Color="Red" Glyph="" /> </SwipeItem.IconImageSource> </SwipeItem> </SwipeItems> </SwipeView.LeftItems> <Grid WidthRequest="300" HeightRequest="60" BackgroundColor="LightGray"> <Label HorizontalOptions="Center" VerticalOptions="Center" Text="오른쪽 밀기" /> </Grid> </SwipeView> </ContentPage> |
▶ MainPage.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
using Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific; namespace TestProject; /// <summary> /// 메인 페이지 /// </summary> public partial class MainPage : ContentPage { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainPage() /// <summary> /// 생성자 /// </summary> public MainPage() { InitializeComponent(); this.swipeView.On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetSwipeTransitionMode(SwipeTransitionMode.Drag); } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 즐겨찾기 스와이프 항목 호출시 처리하기 - favoriteSwipeItem_Invoked(sender, e) /// <summary> /// 즐겨찾기 스와이프 항목 호출시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private async void favoriteSwipeItem_Invoked(object sender, EventArgs e) { await DisplayAlert("INFORMATION", "즐겨찾기 항목을 클릭했습니다.", "확인"); } #endregion #region 삭제 스와이프 항목 호출시 처리하기 - deleteSwipeItem_Invoked(sender, e) /// <summary> /// 삭제 스와이프 항목 호출시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private async void deleteSwipeItem_Invoked(object sender, EventArgs e) { await DisplayAlert("INFORMATION", "삭제 항목을 클릭했습니다.", "확인"); } #endregion } |