I have this XAML code:
<StackLayout Grid.Row="0" Grid.Column="0" Padding="15,10,20,10" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand">
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="tapFavorites" NumberOfTapsRequired="1" />
</StackLayout.GestureRecognizers>
<Label x:Name="faveLabel" FontFamily="FontAwesome" XAlign="Center" FontSize="23">
<Label.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding Favorite}" Value="true">
<Setter Property="TextColor" Value="Red" />
</DataTrigger>
<DataTrigger TargetType="Label" Binding="{Binding Favorite}" Value="false">
<Setter Property="TextColor" Value="Gray" />
</DataTrigger>
</Label.Triggers>
</Label>
</StackLayout>
In my C# code I am familar with setting the Text property of the label by simply specifying like this:
sampleLabel.Text = "ABC"
But this situation is different. Can someone tell me how I can change the color of a label from C# when the label is clicked on.
sampleLabel.TextColor = Color.Red;
– Ketan Dubey