Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created April 12, 2018 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/bd82c9e431bb60a9b30cd82bf0f1c797 to your computer and use it in GitHub Desktop.
Save icebeam7/bd82c9e431bb60a9b30cd82bf0f1c797 to your computer and use it in GitHub Desktop.
Sentimental Tweets: StringToColorConverter.cs
using System;
using System.Globalization;
using Xamarin.Forms;
namespace SentimentalTweets.Helpers
{
public class StringToColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double sentimiento = (double)value;
if (sentimiento < 0.45)
return Color.Red;
else if (sentimiento < 0.55)
return Color.Black;
else
return Color.Green;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment