Вы можете использовать конвертер:
public class LabelMaxLengthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string labelText = value as string;
if (labelText == null)
return value;
const int maxLength = 20;
if (labelText.Length > maxLength)
return labelText.Substring(0, maxLength);
else
return labelText;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
И в вашем xaml сначала определите этот конвертер в ресурсах страниц:
<ContentPage.Resources>
<converters:LabelMaxLengthConverter x:Key="LabelMaxLengthConverter" />
</ContentPage.Resources>
И, наконец, в вашем ярлыке примените конвертер к привязке:
<Label Text="{Binding LabelText, Converter={StaticResource LabelMaxLengthConverter}}" />