Last active
February 25, 2018 02:34
-
-
Save QiMata/b674d8b5a9e8a65910c9 to your computer and use it in GitHub Desktop.
Reuse converters by chaining them together with a custom converter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ValueConverterGroup : List<IValueConverter>, IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
{ | |
return this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture)); | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
{ | |
throw new NotImplementedException(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
x:Class="someclass"> | |
<ContentPage.Resources> | |
<ResourceDictionary> | |
<!-- Converters --> | |
<ValueConverterGroup x:Key="SelectionBackgroundColorConverter"> | |
<EqualsConverter></EqualsConverter> | |
<BooleanToColorConverter TrueColor="{StaticResource GreenBackgroundColor}" | |
FalseColor="{StaticResource GraySeperatorColor}"/> | |
</ValueConverterGroup> | |
</ResourceDictionary> | |
</ContentPage.Resources> | |
</ContentPage> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment