Xamarin Forms Swipe Left/Swipe Right Gestures

后端 未结 8 1054
逝去的感伤
逝去的感伤 2020-12-03 02:46

I want to preface this by saying I\'m completely new to mobile development, Xamarin, C#, .Net.

I\'m working on creating a mobile app using Xamarain Forms and have ru

8条回答
  •  猫巷女王i
    2020-12-03 03:17

    You can always have a look at this simple demo. And use it as follows:

    GestureFrame gi = new GestureFrame
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.FromHex("bf3122"),
            };
    
            gi.SwipeDown += (s, e) =>
            {
                DisplayAlert("Gesture Info", "Swipe Down Detected", "OK");
                ViewModel.SampleCommand.Execute("Swipe Down Detected");
            };
    
            gi.SwipeTop += (s, e) =>
            {
                DisplayAlert("Gesture Info", "Swipe Top Detected", "OK");
                ViewModel.SampleCommand.Execute("Swipe Top Detected");
            };
    
            gi.SwipeLeft += (s, e) =>
            {
                DisplayAlert("Gesture Info", "Swipe Left Detected", "OK");
                ViewModel.SampleCommand.Execute("Swipe Left Detected");
            };
    
            gi.SwipeRight += (s, e) =>
            {
                DisplayAlert("Gesture Info", "Swipe Right Detected", "OK");
                ViewModel.SampleCommand.Execute("Swipe Right Detected");
            };
    
            this.Content = gi;
    

提交回复
热议问题