using System;
using System.Globalization;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace MMEA.Converters
{
/// <summary>
/// Converter to change bool to a opacity
/// </summary>
public class BoolToOpacityConverter : IValueConverter, IMarkupExtension
{
/// <inheritdoc />
public object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
/// <inheritdoc />
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var hasRead = (bool) value;
if (hasRead)
return 0.4;
return 1;
}
/// <inheritdoc />
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}
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