Issue
So, I've been working in Xamarin for a couple years but I have yet to encounter this behavior. I'm not sure if perhaps something else was the cause of this, or if there is a legitimate reason for what happened but let me try to explain.
In my xml I have a standard binding for visibility.
IsVisible="{Binding object1.object2.bool}"
Which works. But it is also visible when object2 is null.
Why is this? if object1 is null, nothing appears. But when object1 exists and object2 is null, the IsVisible somehow is set to true and appears.
Shouldn't it be not visible?
Solution
The default value of IsVisible is true
. When the element is created, that is the value it has.
If the binding fails for any reason, it should still have that default value.
HOWEVER, that doesn't explain why "when object1 is null, nothing appears". I would expect it to be visible in that case as well.
Maybe that is a common situation, so it has a null check for the property (object1
), and treats null
as false
. IMHO, that is incorrect logic: it should do nothing, because it cannot evaluate the path to be either true or false. (So the default true
should still be there.)
If object1
isn't null, I assume it attempts the full path. Internally hits an exception. Does nothing. Thus the default true
is intact.
Answered By - ToolmakerSteve
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.