-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] CompareConverter - No property, BindableProperty, or event found for "ComparingValue", or mismatching type between value and property #1437
Comments
The |
@bijington Thanks for the response. Your suggestion fixed the issue, Thank you so much! For reference, this is the way I implemented it: <ResourceDictionary>
<x:Int32 x:Key="ComparingValue">0</x:Int32>
<toolkit:CompareConverter
x:Key="SaveButtonTextCompareConverter"
ComparingValue="{StaticResource ComparingValue}"
ComparisonOperator="Equal"
FalseObject="Update"
TrueObject="Save" />
</ResourceDictionary> |
@bijington can you please reopen this? It is literally like this in the documentation at https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/converters/compare-converter#using-the-compareconverter |
@hansmbakker I won't reopen this issue but I can open an issue/PR to correct the documentation 👍 |
@bijington still - regarding the behavior - I am surprised it doesn't work as it was documented. Given that this issue is about the behavior - could something be done about that? Having to resort to something like <ContentPage.Resources>
<x:Int32 x:Key="one">1</x:Int32>
<toolkit:CompareConverter
x:Key="isLargerThanOneConverter"
ComparingValue="{StaticResource one}"
ComparisonOperator="Greater"
FalseObject="{x:Boolean False}"
TrueObject="{x:Boolean True}" />
</ContentPage.Resources> really feels awkward, and counter-intuitive. I ran into the same issue because I used it like |
@hansmbakker I was surprised too. Sadly this appears to be a limitation of XAML in combination with using the type of the There are some options though: Use the approach in your exampleI wonder given the values in <ContentPage.Resources>
<toolkit:CompareConverter
x:Key="isLargerThanOneConverter"
ComparingValue="{x:Int32 1}"
ComparisonOperator="Greater"
FalseObject="{x:Boolean False}"
TrueObject="{x:Boolean True}" />
</ContentPage.Resources> Create a strongly typed converterFailing that a cleaner although slightly annoying approach would be to subclass the public class IntegerCompareConverter : CompareConverter<int>
{
} And then you can use it as you desire: <ContentPage.Resources>
<converters:IntegerCompareConverter
x:Key="isLargerThanOneConverter"
ComparingValue="1"
ComparisonOperator="Greater"
FalseObject="{x:Boolean False}"
TrueObject="{x:Boolean True}" />
</ContentPage.Resources> |
@bijington thank you for sharing those hints! Before posting my second comment I actually tried <ContentPage.Resources>
<toolkit:CompareConverter
x:Key="isLargerThanOneConverter"
ComparingValue="{x:Int32 1}"
ComparisonOperator="Greater"
FalseObject="{x:Boolean False}"
TrueObject="{x:Boolean True}" />
</ContentPage.Resources> to avoid the additional Making a specifically-typed subclass could be an option, too. |
Although given some limited testing I have done here you might need to combine both of the examples that I mentioned. I am now wondering whether we could use a |
I said we wouldn't fix this as it wasn't an issue but I have been playing around and will shortly open a PR to show how it can be achieved with a minor structural change to our converter. |
@hansmbakker I don't think my examples would have worked without the changes in PR: #1841. |
Is there an existing issue for this?
Did you read the "Reporting a bug" section on Contributing file?
Current Behavior
In spite of the comparing value having been set, it is showing a message that it was not set.
Expected Behavior
The expectation is the TrueObject return to the Text Property
Steps To Reproduce
Use the code below to reproduce the issue in any page
Page:
ViewModel
Link to public reproduction project repository
https://github.com/MarcosCostaDev/MAUI-sql-server-docker/blob/b1cdbc257396f16715184993f4f2414ec431fb9e/src/TodoMaui/Pages/TodoPage.xaml#L29-L45
Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: