Xamarin Community Toolkit: EqualConverter, NotEqualConverter, and Data Types

Nathan Sokalski 4,116 Reputation points

I am using the EqualConverter & NotEqualConverter IValueConverter(s) from the Xamarin Community Toolkit. I am comparing the TranslationY property of an element to the value of the ConverterParameter as follows:

IsVisible="{Binding TranslationY,Source={x:Reference frmNavigation},Converter={StaticResource Equal},ConverterParameter=57}"
IsVisible="{Binding TranslationY,Source={x:Reference frmNavigation},Converter={StaticResource NotEqual},ConverterParameter=57}"

However, the result is False for both of the above, regardless of the value of TranslationY or the ConverterParameter. Back when I was using UWP, I had a problem like this that was caused by the value & ConverterParameter not being of the same type (TranslationY is a Double, I'm not sure what type the converter views the ConverterParameter as). I solved this by writing my own IValueConverter, but I am wondering if there is any way to avoid needing to do this? Thanks.

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,936 Reputation points


    Welcome to our Microsoft Q&A platform!

    You could compare the source code of EqualConverter class with the other converter class such as IntToBoolConverter. The EqualConverter and NotEqualConverter class don't return a value in the Convert and ConvertBack method.

    The EqualConverter function is not supported for now, you could report an issue or a feature request to the product team on github.

    Source code link:

    Best Regards,

    Jarvan Zhang

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments