MAUI swipe recogniser not fier

Haviv Elbsz 1,886 Reputation points
2022-09-04T09:12:01.997+00:00

This is my page
the swipe recogniser not fier
Please what I miss

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="RazKmoShed.MainPage" Loaded="MainPage_Loaded" x:Name="myContentPage"
FlowDirection="LeftToRight" BackgroundColor="Azure" >

    <ScrollView>  
        <VerticalStackLayout x:Name="vLayout" Margin="10" Spacing="5" >  
  
            <Picker x:Name="ExamplesCombo" SelectedIndexChanged="ExamplesCombo_SelectedIndexChanged"  
                        HorizontalTextAlignment="Center" BackgroundColor="Chartreuse"  
                        Title="Select Help Example" TitleColor="Black" FontAttributes="Bold" >  
                <Picker.ItemsSource>  
                    <x:Array Type="{x:Type x:String}">  
                        <x:String>Mul    Example 1</x:String>  
                        <x:String>Mul    Example 2</x:String>  
                        <x:String>Mul    Example 3</x:String>  
                        <x:String>Mul    Example 4</x:String>  
                        <x:String>Mul    Example 5</x:String>  
                        <x:String>Mul    Example 6</x:String>  
                        <x:String>Mul    Example 7</x:String>  
                        <x:String>Mul    Example 8</x:String>  
                        <x:String>Mul    Example 9</x:String>  
                        <x:String>Mul    Example 10</x:String>  
                        <x:String>Mul    Example 11</x:String>  
                        <x:String>Div    Example 1</x:String>  
                        <x:String>Div    Example 2</x:String>  
                        <x:String>Div    Example 3</x:String>  
                        <x:String>Div    Example 4</x:String>  
                        <x:String>Div    Example 5</x:String>  
                        <x:String>Div    Example 6</x:String>  
                        <x:String>Div    Example 7</x:String>  
                        <x:String>Div    Example 8</x:String>  
                        <x:String>Div    Example 9</x:String>  
                        <x:String>Div    Example 10</x:String>  
                        <x:String>Div    Example 11</x:String>  
                        <x:String>Div    Example 12</x:String>  
                        <x:String>Div    Example 13</x:String>  
                        <x:String>Div    Example 14</x:String>  
                        <x:String>AddSub Example 1</x:String>  
                        <x:String>AddSub Example 2</x:String>  
                        <x:String>Add    Example 1</x:String>  
                        <x:String>Add    Example 2</x:String>  
                        <x:String>Add    Example 3</x:String>  
                        <x:String>Add    Example 4</x:String>  
                        <x:String>Sub    Example 1</x:String>  
                        <x:String>Sub    Example 2</x:String>  
                    </x:Array>  
                </Picker.ItemsSource>  
            </Picker>  
  
            <Picker x:Name="ShortOPCombo" SelectedIndexChanged="ShortOPCombo_SelectedIndexChanged"  
                        HorizontalTextAlignment="Center" BackgroundColor="Pink"  
                        Title="Select Puzzle Type" TitleColor="Black" FontAttributes="Bold" >  
                <Picker.ItemsSource>  
                    <x:Array Type="{x:Type x:String}">  
                        <x:String>Mul Puzzle</x:String>  
                        <x:String>Div Puzzle</x:String>  
                        <x:String>AddSub Puzzle</x:String>  
                        <x:String>Add Puzzle</x:String>  
                        <x:String>Sub Puzzle</x:String>  
                        <x:String>Sqr Puzzle</x:String>  
                    </x:Array>  
                </Picker.ItemsSource>  
            </Picker>  
  
            <Picker x:Name="nonParticipantcombo" SelectedIndexChanged="nonParticipantcombo_SelectedIndexChanged"  
                        HorizontalTextAlignment="Center" BackgroundColor="Orange"  
                        Title="Select Non Participants Digits" TitleColor="Black" FontAttributes="Bold" >  
                <Picker.ItemsSource>  
                    <x:Array Type="{x:Type x:String}">  
                        <x:String>Use Any Non Participants Digits</x:String>  
                        <x:String>Use 0 Non Participants Digits</x:String>  
                        <x:String>Use 1 Non Participants Digits</x:String>  
                        <x:String>Use 2 Non Participants Digits</x:String>  
                        <x:String>Use 3 Non Participants Digits</x:String>  
                        <x:String>Use 4 Non Participants Digits</x:String>  
                        <x:String>Use 5 Non Participants Digits</x:String>  
                        <x:String>Use 6 Non participants Digits</x:String>  
                        <x:String>Use 7 Non participants Digits</x:String>  
                        <x:String>Use 8 Non participants Digits</x:String>  
                        <x:String>Use 9 Non participants Digits</x:String>  
                    </x:Array>  
                </Picker.ItemsSource>  
            </Picker>  
  
            <HorizontalStackLayout >  
                <CheckBox x:Name="L2RAlfaBetCKB" IsChecked="False"  
                      CheckedChanged="L2RAlfaBetCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label    Text="Checked = RightToLeft Writing" FontAttributes="Bold"  
                      HorizontalOptions="Start" VerticalOptions="Center" />  
            </HorizontalStackLayout>  
  
            <Editor x:Name="InputTB"   
                        BackgroundColor="LightSkyBlue" FontSize="16" FlowDirection="LeftToRight"  
                        TextChanged="InputTB_TextChanged" TextColor="Black"  
                        Placeholder="Enter alphametic puzzle here" FontAttributes="Bold"  
                        PlaceholderColor="Blue" FontFamily="NCourier"  
                        HorizontalOptions="Fill" VerticalOptions="Start"   
                        HeightRequest="500" WidthRequest="320" >  
<!--  
                <Editor.GestureRecognizers>  
                    <SwipeGestureRecognizer Direction="Left" Swiped="SwipeGestureRecognizer_Swiped"/>  
                    <SwipeGestureRecognizer Direction="Right" Swiped="SwipeGestureRecognizer_Swiped"/>  
                    <SwipeGestureRecognizer Direction="Up" Swiped="SwipeGestureRecognizer_Swiped"/>  
                    <SwipeGestureRecognizer Direction="Down" Swiped="SwipeGestureRecognizer_Swiped"/>  
                    <SwipeGestureRecognizer Threshold="50" />  
                </Editor.GestureRecognizers>  
-->  
            </Editor>  
  
            <HorizontalStackLayout >  
                <CheckBox x:Name="useDigitsItselfCKB" IsChecked="False"  
                      CheckedChanged="useDigitsItselfCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label    Text="Use Digit Itself Value" FontAttributes="Bold"  
                      HorizontalOptions="Start" VerticalOptions="Center" />  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout >  
                <CheckBox x:Name="alphaCKB" IsChecked="False"  
                      CheckedChanged="alphaCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label    Text="Alpha Free" FontAttributes="Bold"  
                      HorizontalOptions="Start" VerticalOptions="Center" />  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout >  
                <CheckBox x:Name="fromToCKB" IsChecked="False"  
                      CheckedChanged="fromToCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label    Text="Asterisk Free" FontAttributes="Bold"  
                      HorizontalOptions="Start" VerticalOptions="Center" />  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout >  
                <CheckBox x:Name="UseOddsEvensCKB" IsChecked="False"  
                      CheckedChanged="UseOddsEvensCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label    Text="EO Use Evens and Odds" FontAttributes="Bold"           
                      HorizontalOptions="Start" VerticalOptions="Center" />  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout >  
                <CheckBox x:Name="shiftingsCKB" IsChecked="False"  
                      CheckedChanged="shiftingsCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label    Text="Use Terms Shiftings" FontAttributes="Bold"  
                      HorizontalOptions="Start" VerticalOptions="Center" />  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout >  
                <CheckBox x:Name="ZerosCKB" IsChecked="False"  
                      CheckedChanged="ZerosCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label    Text="Remove Zero Terms" FontAttributes="Bold"           
                      HorizontalOptions="Start" VerticalOptions="Center" />  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout Spacing="10" >  
                <CheckBox x:Name="UseFromDigitsCKB" IsChecked="False"  
                      CheckedChanged="UseFromDigitsCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label Text="Use These Digits ==>" FontAttributes="Bold"           
                      HorizontalOptions="Start" VerticalOptions="Center" />  
  
                <Entry   x:Name="UseFromDigitsTB" HorizontalOptions="FillAndExpand"  
                         BackgroundColor="Cyan" MinimumWidthRequest="300" FontAttributes="Bold"                   
                         Text="*4 1 2 3 4    " TextChanged="UseFromDigitsTB_TextChanged" />  
  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout Spacing="10" >  
                <CheckBox x:Name="UseRepetitionCKB" IsChecked="False"  
                      CheckedChanged="UseRepetitionCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label Text="Use Digit Repeat ==>" FontAttributes="Bold"           
                      HorizontalOptions="Start" VerticalOptions="Center" />  
  
  
                <Entry   x:Name="UseRepetitionTB" HorizontalOptions="FillAndExpand"  
                         BackgroundColor="Cyan"  MinimumWidthRequest="300" FontAttributes="Bold"                   
                         Text="= 24    " TextChanged="UseRepetitionTB_TextChanged" />  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout Spacing="10" >  
                <CheckBox x:Name="TermsDiffDigitsCKB" IsChecked="False"  
                      CheckedChanged="TermsDiffDigitsCKB_CheckedChanged"  
                      HorizontalOptions="Center" VerticalOptions="Center" />  
  
                <Label Text="Use Terms Diff Digits ==>" FontAttributes="Bold"           
                      HorizontalOptions="Start" VerticalOptions="Center" />  
  
                <Entry   x:Name="TermsDiffDigitsTB" HorizontalOptions="FillAndExpand"  
                         BackgroundColor="Cyan"  MinimumWidthRequest="300" FontAttributes="Bold"                   
                         Text="= 2    " TextChanged="TermsDiffDigitsTB_TextChanged" />  
            </HorizontalStackLayout>  
  
            <HorizontalStackLayout Spacing="10" >  
                <Label HorizontalOptions="Start" VerticalOptions="Center"  
                       FontAttributes="Bold"  
                       Text="Use Base Number ==>" />  
  
                <Entry   x:Name="baseXTB"  HorizontalOptions="FillAndExpand" Text="10    "  
                         BackgroundColor="Cyan"  MinimumWidthRequest="300" FontAttributes="Bold"  
                         TextChanged="baseXTB_TextChanged" VerticalOptions="Center" />  
            </HorizontalStackLayout>  
  
            <Editor  x:Name="OutputTB"  
                         IsReadOnly="False" BackgroundColor="LightGreen" FontSize="16"  
                         TextChanged="OutputTB_TextChanged" TextColor="Black"  
                         Placeholder="Solutions go's here" FontAttributes="Bold"  
                         PlaceholderColor="Blue" FontFamily="NCourier"  
                         HorizontalOptions="Fill" VerticalOptions="Start"  
                         HeightRequest="500" WidthRequest="320" >  
<!--  
                <Editor.GestureRecognizers>  
                    <SwipeGestureRecognizer Direction="Left" Swiped="SwipeGestureRecognizer_Swiped"/>  
                    <SwipeGestureRecognizer Direction="Right" Swiped="SwipeGestureRecognizer_Swiped"/>  
                    <SwipeGestureRecognizer Direction="Up" Swiped="SwipeGestureRecognizer_Swiped"/>  
                    <SwipeGestureRecognizer Direction="Down" Swiped="SwipeGestureRecognizer_Swiped"/>  
                    <SwipeGestureRecognizer Threshold="50" />  
                </Editor.GestureRecognizers>  
-->  
  
            </Editor>  
  
            <ProgressBar x:Name="progressBar"  Progress="0" ProgressColor="Blue" />  
  
            <Button  x:Name="RunButton" Text="Start" BackgroundColor="#512BD4"  
                      HorizontalOptions="Center" VerticalOptions="Center"  
                      CornerRadius="20" BorderColor="Black" TextColor="White"  
                      BorderWidth="2" HeightRequest="40" WidthRequest="140"  
                      Clicked="RunButton_Clicked" FontAttributes="Bold" />  
  
        </VerticalStackLayout>  
    </ScrollView>  
  
</ContentPage>  
  
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,853 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,221 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 35,121 Reputation points Microsoft Vendor
    2022-09-05T08:37:10.77+00:00

    Hello,

    I've tested your code on my side, and it worked fine.

    You could try the following steps:

    Step1: Change

    Step1: Please uncomment your GestureRecognizers.

    Step2: On my side, I used DisplayAlert("Test","Swiped","OK") in SwipeGestureRecognizer_Swiped for testing.

    In addition, if you used the following code, you will find case SwipeDirection.Up & Down will never be called.

       switch (e.Direction)  
           {  
               case SwipeDirection.Left:  
                   // Handle the swipe  
                   break;  
               case SwipeDirection.Right:  
                   // Handle the swipe  
                   break;  
               case SwipeDirection.Up:  
                   // Handle the swipe  
                   break;  
               case SwipeDirection.Down:  
                   // Handle the swipe  
                   break;  
           }  
    

    It is caused by the ScrollView, you could change it to VerticalStackLayout.

    You need to use Custom Renderer to deal with up down scrolling.

    You could refer to this thread on StackOverflow: Xamarin.Forms. SwipeGesture and ScrollView don't work together on Android - Stack Overflow.

    In MAUI, we could use the custom renderer by the following way:

       builder   
           .UseMauiCompatibility()  
           .ConfigureMauiHandlers((handlers) => {  
       #if ANDROID  
           handlers.AddHandler(typeof(Shell), typeof(ShellTitle.Platforms.Android.MyRenderer));  
       #endif  
       #if IOS  
           handlers.AddHandler(typeof(Shell), typeof(ShellTitle.Platforms.iOS.MyRenderer));  
       #endif  
           })  
    

    You could refer to Using Custom Renderers in .NET MAUI to get more details.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful