Xamarin Community Toolkit: EqualConverter, NotEqualConverter, and Data Types

Nathan Sokalski 4,111 Reputation points
2020-12-22T18:02:39.093+00:00

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.

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

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,961 Reputation points
    2020-12-25T07:49:57.507+00:00

    Hello,​

    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:
    https://github.com/xamarin/XamarinCommunityToolkit/tree/main/src/CommunityToolkit/Xamarin.CommunityToolkit/Converters

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.