-
Notifications
You must be signed in to change notification settings - Fork 697
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
x:Bind Function with Boolean return can't be bound to Visibility property #5514
Comments
@RealTommyKlein FYI |
This is still an issue today. Any progress on that regard? |
Encountered this again today, as it's not just static functions but any functions. One of the most common things to do is inverting a Ideally, one could just do this: <Border Visibility="{x:Bind MyBoolProperty.Equals(x:False), Mode=OneWay}"/> And be done, but with this bug, you now need a custom converter, or a custom function to return specifically a |
Bump |
This comment has been minimized.
This comment has been minimized.
@Jay-o-Way no, the built-in converter is only for properties, this bug is about the second part of the doc note about it not working automatically with functions that return a bool:
I imagine this should just be a matter of the x:Bind generator detecting a boolean return type of a function bound to a Visibility parameter and applying the same logic it does for properties? |
Describe the bug
If you have a function you can use with x:Bind that returns a
bool
, it can't also be used for a property expecting aVisibility
type. This works fine when binding abool
based property to aVisibility
type with x:Bind, but not with a function. Functions are missing the implicit type conversion step done elsewhere for XAML. 🙁This means that we have to duplicate our function to work for both boolean and Visibility based properties. 🙁
It'd be great for the
x:Bind
system to be able to do the same implicit type conversions done elsewhere with properties.Steps to reproduce the bug
You can see in the following example that a
bool
value can be bound directly to the visibility of an item (the green rectangle) as well as negated with a function and bound to abool
based property (checkbox).However, trying to use that same function to bind to a
Visibility
based property results in an error about types:Expected behavior
Able to use the same
bool
based function withx:Bind
forVisibility
based types. Ideally, any implicit conversions between types can be performed.Because of this issue it means you have to create functions explicitly for both boolean values and Visibility values even if the logic and input to that function is the same.
Version Info
The example above is with the Windows App SDK 0.8.1, but this is also a problem in WUX based OS xaml. I tested with WinUI 3 to ensure that it wasn't fixed already there, but the problem remains. 🙁
Windows app type:
Additional context
Related to:
The text was updated successfully, but these errors were encountered: