Forum Xamarin Xamarin.Forms

Add text to the end of a label using Styles?

nmrl64nmrl64 Member ✭✭

Hi everyone,
I'm building a data entry app in Xamarin.Forms. Entry pages have StackLayouts, and then multiple Pickers or Entries with a Label above each one telling the user what the field is. I have a StyleClass stored in my App.xaml that sets every one of these Labels to have TextColor = Black, HorizontalOptions = Start, etc. etc. I'd like to know if there's a way I could add the text "(required)" in red at the end of the Label's text, by using a StyleClass. So for example, every Picker is for a different data set, therefore the text of each Label above it needs to be set manually from the relevant Page.xaml file. I'm asking if there's a way I can set that text from the Page.xaml, and then have the StyleClass as defined in App.xaml apply more text to the end in a different color. Aware that it might not be possible, but any help is appreciated. Thanks!

Best Answer


  • nmrl64nmrl64 Member ✭✭

    Thanks for that Jarvan! Another thing I worked out was by nesting a horizontal StackLayout inside of the existing vertical StackLayout, I can get two labels to be side-by-side in the way that I want. Just needed to set both labels HorizontalOptions to "Start" and then they're arranged in the way I needed.

Sign In or Register to comment.