protected override IBound ReApply(IDictionary <Type, IStyle> styles, IBound styleBound, IBound maxBound) { IStyleHelper helper = StyleSheetContext.Current.CreateHelper(styles, CurrentStyleSheet, this); if (styles.Count > 0) { // text-format ITextFormat textFormat; if (helper.TryGet(out textFormat)) { _textFormat = textFormat.Format; SetText(); } // background color, background image, borders Drawable background; if (helper.BackgroundChanged(CurrentStyleSheet, Frame.Bound, out background)) { using (background) SetBackground(background); } // font helper.SetFontSettings(_view, styleBound.Height); // text color ITextColor textColor; if (helper.TryGet(out textColor)) { _textColor = textColor.ToColorOrTransparent(); _view.SetTextColor(_textColor); } //selected color ISelectedColor selectedColor; if (helper.TryGet(out selectedColor)) { _selectedColor = selectedColor.ToNullableColor(); } //selected background ISelectedBackground selectedBackground; if (helper.TryGet(out selectedBackground)) { _selectionBehaviour.SelectedColor = selectedBackground.ToNullableColor(); } // word wrap IWhiteSpace whiteSpace; if (helper.TryGet(out whiteSpace)) { _singleLine = whiteSpace.Kind == WhiteSpaceKind.Nowrap; _view.SetSingleLine(_singleLine); } // text align ITextAlign textAlign; if (helper.TryGet(out textAlign)) { ApplyTextAlign(textAlign.Align); if (_singleLine) { _view.Ellipsize = textAlign.Align == TextAlignValues.Right ? TextUtils.TruncateAt.Start : TextUtils.TruncateAt.End; } } // text padding int pl = helper.GetSizeOrDefault <IPaddingLeft>(styleBound.Width, _view.PaddingLeft).Round(); int pt = helper.GetSizeOrDefault <IPaddingTop>(styleBound.Height, _view.PaddingTop).Round(); int pr = helper.GetSizeOrDefault <IPaddingRight>(styleBound.Width, _view.PaddingRight).Round(); int pb = helper.GetSizeOrDefault <IPaddingBottom>(styleBound.Height, _view.PaddingBottom).Round(); _view.SetPadding(pl, pt, pr, pb); } IBound bound = SizeToContent(styleBound, maxBound, CurrentStyleSheet.Helper); // reload image with new size helper.ReloadBackgroundImage(CurrentStyleSheet, bound, this); return(bound); }