Is there any way to set the default text color to a specific color for all the page elements that contain text?
It doesn't make sense to me that I need to set a 'TextColor' attribute for every element that contain text.
Thanks!
You can set the style of the elements containing text in the App.xaml. This will set the TextColor for all Labels, Buttons,... you use in your app:
<Style TargetType="Label">
<Setter Property="TextColor" Value="Red" />
</Style>
<Style TargetType="Button">
<Setter Property="TextColor" Value="Red" />
</Style>
<Style TargetType="Entry">
<Setter Property="TextColor" Value="Red" />
</Style>
<Style TargetType="Editor">
<Setter Property="TextColor" Value="Red" />
</Style>
...
Unfortunately you will have to add a new Style tag for all Visual Elements containing text. I've been searching for a cleaner way to define styles for all elements with text a while ago. But this seems to be the cleanest way to do it...
Hopefully Xamarin.Forms will add a more generic way to handle the styling.
You can use Styles as shown above by DenseCrab. And you could also create a different class that derives from the Label class. And you can set some default properties like color in there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With