Open michael-hawker opened 3 years ago
@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 bool
in order to show something when a value is false.
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 Visibility
value. ☹
Bump
Hey all, I'm reading https://learn.microsoft.com/nl-nl/windows/uwp/xaml-platform/x-bind-markup-extension#remarks and there we see that the BoolToVisibility converter is built-in. Does that "negate" this issue?
@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:
can bind a Visibility property to a Boolean without creating a converter. Note that this is not a feature of function binding, only property binding.
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. 🙁
Additional context Related to: