Touch Effect | Xamarin.Forms | Xamarin Community Toolkit

  • Would you like to change Opacity when the StackLayout is pressed? — No problem.
  • Do you want to increase the Scale when the Grid is hovered by the mouse cursor? — Easy!
  • Ohh, you want to replicate native platform button behavior (Tilt for UWP, Ripple for Android), don’t you? — No problem, sir. That’s supported.
  1. First of all, we should add Xamarin.CommunityToolkit to all of your Xamarin.Forms projects (including platform projects iOS, Android, UWP, etc.). Keep in mind that XCT requires Xamarin.Forms v.5. That’s it! No other initialization required (Quite easy for far, right :P?)
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
<ContentView                              xct:TouchEffect.AnimationDuration="500"                              xct:TouchEffect.AnimationEasing="CubicInOut"
xct:TouchEffect.PressedScale="1.2" xct:TouchEffect.Command={Binding PressedCommand}>
<Image Source="{Binding Image}" />
<ContentView>
<StackLayout                              xct:TouchEffect.NativeAnimation="True"                                                                             xct:TouchEffect.Command={Binding PressedCommand}>
<Image Source="{Binding Image}" />
<StackLayout>
<ContentView                              xct:TouchEffect.LongPressCommand="{Binding LongPressedCommand}">                       
<Image Source="{Binding Image}" />
<ContentView>
  1. I wish to make the “Learn more” label touch responsive.
  2. I want to make the back button touch responsive.
  3. I want to open a detailed page by the long press over the hero picture.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Pass the Certified Kubernetes Application Developer (CKAD) Exam

How to Deploy MEVN Stack on Azure AKS using HELM

Gradle Build — A Modern Build Tools

Hyper-V vs VMware vSphere, Which Solution Is Right for You?

How to incentivize adoption without token: Fuji Climbing (2/2)

Sinatra Portfolio Project — The Art of Debugging

Go Modules from the private repository in the pipeline

How to transform real-time data before its gets stored

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrei Misiukevich

Andrei Misiukevich

More from Medium

Route handler filters with .Net 7 preview 3

Avatar View | Xamarin.Forms | Xamarin Community Toolkit

ASP.NET Core MVC WebApplication

How to solve OutOfMemoryException .Net