Skip to content

Instantly share code, notes, and snippets.

@Rene-Sackers
Created September 4, 2016 09:07
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 Rene-Sackers/49cc7daf92d0601c871a129e0dc299e6 to your computer and use it in GitHub Desktop.
Save Rene-Sackers/49cc7daf92d0601c871a129e0dc299e6 to your computer and use it in GitHub Desktop.
A converter for use in XAML to convert a boolean to any true/false value.
public class BoolToAnyConverter : IValueConverter
{
public object TrueValue { get; set; }
public object FalseValue { get; set; }
public object Convert(object value, Type targetType, object parameter, string language)
{
return (bool)value ? TrueValue : FalseValue;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return value == TrueValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment