c# - Label TapGesture doesnt fire Xamarin Forms -
i trying add tapgesturerecognizer label.
sliderabout.gesturerecognizers.add(new tapgesturerecognizer { command = new command(() => openaboutappasync()), }); sliderabout label wich set in xaml , works correctly.
<scrollview grid.row="1"> <grid verticaloptions="start" horizontaloptions="start" margin="20,20,0,0"> <grid.rowdefinitions> <rowdefinition height="60"/> </grid.rowdefinitions> <label x:name="sliderabout" text="Über die app" grid.row="2" textcolor="white" fontfamily="open sans light" fontsize="medium"/> </grid> </scrollview> the code gets run ( put in class constructor)
but method doesnt fire when tap label... why wont fire?
thanks help!
you can add gesture recognizer directly xaml , action in code behind or view model if you're using mvvm approach. in case this:
<label x:name="sliderabout" text="Über die app" grid.row="2" textcolor="white" fontfamily="open sans light" fontsize="medium"> <label.gesturerecognizers> <tapgesturerecognizer tapped="onlabeltapped" /> </labelgesturerecognizers> </label> and in code behind
private void onlabeltapped (object sender, eventargs e) { //your code here }
Comments
Post a Comment