using System; using System.Globalization; using System.Windows.Data; using System.Windows.Markup; using System.Windows.Media; namespace Gestor.Common.Converters { public class NegativoColorConverter : MarkupExtension, IValueConverter { public NegativoColorConverter() { } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null || string.IsNullOrEmpty(value.ToString())) { return new SolidColorBrush(Colors.Black); } if (!value.ToString().Contains("-")) { return new SolidColorBrush(Colors.Black); } return new SolidColorBrush(Colors.Red); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return null; } public override object ProvideValue(IServiceProvider serviceProvider) { return this; } } }