using System;
using System.Globalization;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace MMEA.Converters
{
/// <summary>
/// Converter to inverse the boolean value for views
/// </summary>
public class InverseBoolConverter : IValueConverter, IMarkupExtension
{
/// <inheritdoc />
public object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
/// <inheritdoc />
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return !(bool) value;
}
/// <inheritdoc />
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return !(bool) value;
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter