NativeAnimation on StackLayout

vanKraster 181 Reputation points
2022-01-21T11:15:22.15+00:00

Hi to all,

xct declared as xmlns:xct="http://xamarin.com/schemas/2020/toolkit"

I want to add NativeAnimation to a stacklayout with a TapGestureRecognizer but I have this problem:
If I add xct:TouchEffect.NativeAnimation="True" to a StackLayout and inside that StackLayout I have a Button with a Command when I tap on the button It raises the StackLayout's TapGesture instead of Button's Command and If I remove xct:TouchEffect.NativeAnimation="True" of StackLayout it all works as expected BUT I don't have an Animation to show what stacklayout I tapped...

Please help me

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,289 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,016 Reputation points Microsoft Vendor
    2022-01-24T02:31:18.227+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    I get the same issue as yours, please open a issue in Xamarin.CommunityToolkit Github page.

    If the tag outside your <Stacklayout> is <ContentPage>, you can add xct:TouchEffect to <ContentPage> like following code. Button click command and xct:TouchEffect worked as normal in my side.

       <?xml version="1.0" encoding="utf-8" ?>  
       <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"  
                    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
                    xmlns:xct="http://xamarin.com/schemas/2020/toolkit"  
                    xmlns:app8="clr-namespace:App8"  
                    xct:TouchEffect.Command="{Binding PressedCommand}"      
                    xct:TouchEffect.NativeAnimation="True"       
                    xct:TouchEffect.AnimationDuration="500"                               
                    xct:TouchEffect.AnimationEasing="CubicInOut"  
                    xct:TouchEffect.PressedScale="1.2"   
                    x:Class="App8.MainPage">  
           <StackLayout>  
               <StackLayout.BindingContext>  
                   <app8:MyWiewModel  />  
               </StackLayout.BindingContext>  
               <Button Text="click" Command="{Binding NaviCommand}"></Button>  
           </StackLayout>  
         
       </ContentPage>  
    

    Best Regards,

    Leon Lu


    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 comments No comments

0 additional answers

Sort by: Most helpful