Display label text in uppercase using xaml in Xamarin.Forms

As you're aware you can do this from the code behind as such:

string data = "my data";
UILabel myLabel = new UILabel();
myLabel.Text = data.ToUpper();

So bearing in mind that you don't want to do it this way you would need to derive from UILabel and create your own, then simply add the ToUpper() onto the end of the get;set; values of the Text property.

using CoreGraphics;
using System;
using UIKit;

namespace MyApp.Controls
{
    partial class Control_UpperLabel : UILabel
    {
        public Control_UpperLabel IntPtr handle) : base(handle)
        {
               //
        }

        public Control_UpperLabel()
        {
               //
        }

        public override void Draw(CGRect rect)
        {
            base.Draw(rect);
        }

        public override string Text { get => base.Text.ToUpper(); set => base.Text = value.ToUpper(); }    
   }
}

EDIT: As per comments below, here is an alternative solution for Xamarin.Forms

This uses a value converter as part of a binding solution. It's also been slightly amended to use the suggestion by clint in the comments below. Thanks.

public class StringCaseConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        switch ((parameter as string).ToUpper()[0]) 
        { 
        case 'U': 
            return ((string)value).ToUpper(); 
        case 'L': 
            return ((string)value).ToLower(); 
        default: 
            return ((string)value);
        };
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotSupportedException();
    }
}

It would be used in the XAML as such:

Text="{Binding Text, Converter={StaticResource caseConverter}, ConverterParameter=u}}"

You can use Label.TextTransform with TextTransform.Uppercase.

XAML

<Label TextTransform="Uppercase" />

C#

var label = new Label
{
    TextTransform = TextTransform.Uppercase
};