private void UpdateTooltip(string weatherPublishedDateText, string weatherUpdatedDateText, float?locationDistance, int?weatherRequestCount, int?googleMapsGeocodingApiCount) { if (_tooltipWindow == null || _tooltipWindow.IsDisposed) { OnCreateTooltip(); } try { _tooltipWindow.TooltipText = string.Empty; } catch (ObjectDisposedException) { OnCreateTooltip(); } var weatherSection = GetString(Resource.String.WeatherTitle); var tooltip = string.Format("{0}{1}{2} {3}", weatherSection, System.Environment.NewLine, GetString(Resource.String.RequestCountMessage), weatherRequestCount ?? 0); if (locationDistance.HasValue) { tooltip = string.Format("{0}{1}{2} {3:N3} {4}", tooltip, System.Environment.NewLine, GetString(Resource.String.LocationDistance), locationDistance / 1000.0, _weatherTools?.DistanceUnitToString(DistanceUnit.Kilometer)); } if (!string.IsNullOrEmpty(weatherPublishedDateText)) { tooltip = string.Format("{0}{1}{2}", tooltip, System.Environment.NewLine, weatherPublishedDateText); } if (!string.IsNullOrEmpty(weatherUpdatedDateText)) { tooltip = string.Format("{0}{1}{2}", tooltip, System.Environment.NewLine, weatherUpdatedDateText); } var googleMapsGeocodingApiSectionStart = 0; var googleMapsGeocodingApiSectionEnd = 0; if (googleMapsGeocodingApiCount.HasValue) { var googleMapsGeocodingApiSection = GetString(Resource.String.GoogleMapsGeocodingApiTitle); googleMapsGeocodingApiSectionStart = tooltip.Length + 1; googleMapsGeocodingApiSectionEnd = googleMapsGeocodingApiSectionStart + googleMapsGeocodingApiSection.Length + 1; tooltip = string.Format("{0}{1}{1}{2}{1}{3} {4}", tooltip, System.Environment.NewLine, googleMapsGeocodingApiSection, GetString(Resource.String.RequestCountMessage), googleMapsGeocodingApiCount); } var textFormatted = new SpannableString(tooltip); textFormatted.SetSpan(new UnderlineSpan(), 0, weatherSection.Length, SpanTypes.ExclusiveExclusive); if (googleMapsGeocodingApiSectionStart > 0) { textFormatted.SetSpan(new UnderlineSpan(), googleMapsGeocodingApiSectionStart, googleMapsGeocodingApiSectionEnd, SpanTypes.ExclusiveExclusive); } _tooltipWindow.TooltipTextFormatted = textFormatted; }