This might be a stupid question but I just wanted to know as I am new to Xamarin.forms.
Can we set 'GestureRecognizers' in Style. For example I want to create a style for lable like below...
<Style TargetType="Label" x:Key="LabelStyle">
<Setter Property="GestureRecognizers">
<Setter.Value>
<TapGestureRecognizer Command="{Binding EditSectionCommand}"/>
</Setter.Value>
</Setter>
</Style>
but it shows an compile time error 'Can't resolve GestureRecognizers on Label'.
Any help is appreciated.
You can't set this
GestureRecognizers
property in the style. BecauseGestureRecognizers
is not a bindable property in the default Label.If you do want to use Style to configure the
TapGestureRecognizer
, you can try to construct a customized label. Define a bindable command property which handles theTapGestureRecognizer
event of the label:At last you can use this command in the XAML: