foreach (var span in formattedString.Spans)
{
Native.Span nativeSpan = new Native.Span();
- nativeSpan.FormattedText = span.Text;
- nativeSpan.FontAttributes = span.FontAttributes == FontAttributes.None ? Element.FontAttributes : span.FontAttributes;
- nativeSpan.FontFamily = span.FontFamily == null ? Element.FontFamily : span.FontFamily;
- nativeSpan.FontSize = span.FontSize == Device.GetNamedSize(NamedSize.Default, typeof(Label), true) ? Element.FontSize : span.FontSize;
+ nativeSpan.Text = span.Text;
+ nativeSpan.FontAttributes = span.FontAttributes;
+ nativeSpan.FontFamily = span.FontFamily;
+ nativeSpan.FontSize = span.FontSize;
nativeSpan.LineBreakMode = Control.LineBreakMode;
- nativeSpan.HorizontalTextAlignment = Control.HorizontalTextAlignment;
+ nativeSpan.VerticalTextAlignment = Control.VerticalTextAlignment;
+ nativeSpan.ForegroundColor = span.ForegroundColor.ToNative();
+ nativeSpan.BackgroundColor = span.BackgroundColor.ToNative();
- if (span.ForegroundColor.IsDefault)
- nativeSpan.ForegroundColor = Element.TextColor.IsDefault ? s_defaultForegroundColor : Element.TextColor.ToNative();
- else
- nativeSpan.ForegroundColor = span.ForegroundColor.ToNative();
-
- if (span.BackgroundColor.IsDefault)
- nativeSpan.BackgroundColor = Element.BackgroundColor.IsDefault ? s_defaultBackgroundColor : Element.BackgroundColor.ToNative();
- else
- nativeSpan.BackgroundColor = span.BackgroundColor.ToNative();
nativeString.Spans.Add(nativeSpan);
}
void UpdateTextColor()
{
Control.TextColor = Element.TextColor.IsDefault ? s_defaultTextColor : Element.TextColor.ToNative();
- UpdateFormattedText();
}
void UpdateTextAlignment()
{
+ if (Control.FormattedText != null)
+ {
+ foreach (var span in Control.FormattedText.Spans)
+ {
+ span.VerticalTextAlignment = Element.VerticalTextAlignment.ToNative();
+ }
+ }
+
Control.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative();
Control.VerticalTextAlignment = Element.VerticalTextAlignment.ToNative();
- UpdateFormattedText();
}
void UpdateFontProperties()
Control.FontSize = Element.FontSize;
Control.FontAttributes = Element.FontAttributes;
Control.FontFamily = Element.FontFamily;
- UpdateFormattedText();
}
void UpdateLineBreakMode()
{
+ if (Control.FormattedText != null)
+ {
+ foreach (var span in Control.FormattedText.Spans)
+ {
+ span.LineBreakMode = ConvertToNativeLineBreakMode(Element.LineBreakMode);
+ }
+ }
Control.LineBreakMode = ConvertToNativeLineBreakMode(Element.LineBreakMode);
- UpdateFormattedText();
}
Native.LineBreakMode ConvertToNativeLineBreakMode(LineBreakMode mode)