Xamarin.forms: [Bug] x:DataType={x:Type SomeType} breaks Compiled binding

Created on 11 Jun 2019  Â·  16Comments  Â·  Source: xamarin/Xamarin.Forms

Description

Steps to Reproduce

  1. Set x:DataType to "{x:Type SomeType}" instead of "SomeType"
  2. Try to bind to some non-existing property

Expected Behavior

Compiler should report an error that such property doesn't exist, just like it would with "SomeType".

Actual Behavior

No errors by compiler.

Basic Information

While this is not critical bug, it annoys me, because it brings inconsistency. As we know, we can use both expressions ("{x:Type SomeType}" or "SomeType") in Styles or DataTemplates. I prefer "{x:Type SomeType}" expression because text is rendered in different color so it pops up visually.

Xaml </> binding ⛓ 4 invalid bug

Most helpful comment

I know it's closed, but having x:Type has the big advantage to get intellisense in XAML (at least with resharper, don't know without it)

All 16 comments

x:DataType expects a string literal, not a {x:Type} markup extension. This should throw an exception, I wonder why it does not. We should investigate that

This markup was valid in Forms until Forms 4.1.

x:DataType with {x:Type} markup extension never worked, and was silently ignored (bindings weren't compiled).

This is why, with #5335 (fixing #5330), it now throws at compilation time. This is not a bug, this is the intended behavior.

Wait wait wait... @StephaneDelcroix
What about x:DataType={x:Null} now throwing an exception, while being totally valid ?
This is a really annoying regression !

@tranb3r that's a good point. please open a new issue while I start working on a fix

btw, assigning x:Null never was a feature, but a fortuitous side effect of nulling the datatype in unrecognized cases

@StephaneDelcroix It's already logged at https://github.com/xamarin/Xamarin.Forms/issues/6648 (where, despite the title, it's about x:Null).

thx @davidbritch. missed that one, as I was off last week

btw, assigning x:Null never was a feature, but a fortuitous side effect of nulling the datatype in unrecognized cases

Maybe it's not a feature, but it's the only workaround for several bugs in Xamarin Forms.
For example this one: https://github.com/xamarin/Xamarin.Forms/issues/5240

@StephaneDelcroix May we know, why Xamarin team decided to not accept {x:Type} as x:DataType value? I know it wasn't accepted before, I'm just wondering why you decided not to follow rest of XAML world now. Thanks.

I'm just wondering why you decided not to follow rest of XAML world now

we're actually leading here with Compiled Bindings, but whatever.

It's a technical limitation. If that's really important to some of you, please open an enhancement request, not a bug, asking for this. This is something we could implement, if it really makes a difference for some of you.

love

Stephane

I know it's closed, but having x:Type has the big advantage to get intellisense in XAML (at least with resharper, don't know without it)

@mzimdars-gms-online-de I'm planning to bring x:Type support for x:DataType on 4.3

@mzimdars-gms-online-de I'm planning to bring x:Type support for x:DataType on 4.3

Now I'm thoroughly confused. Something that was apparently working perfectly well ("{x:type..." in xaml) was removed. This prevents the previously perfectly functional solution from building. The workaround is to remove x:type thereby losing useful functionality (Intellisense lookup). Your solution is to add "{x:type..." support back in at some future date.

We've just updated to the latest Xamarin forms (4.2.0.815419, Sep 2019) and this feature is still not implemented so now we have to update all our XAML so that we can lose Intellisense functionality in them. Presumably (hopefully?) at some point in the future we will be able to add "x:type.." back in.

Is there an ETA on when we can restore our XAML and get back to where we were originally?

Because right now from where we're sitting this all seems like a pointless change that ultimately does nothing but waste our time and annoy us.

Hi @AndrueCope

Compiled bindings have never supported x:Type until Xamarin.Forms 4.3 (currently a pre-release). Some versions of Xamarin.Forms just silently ignored compiled bindings that were set using the x:Type markup extension, and some versions of Xamarin.Forms threw an error.

In Xamarin.Forms 4.2 and earlier, when using a compiled binding, the binding had to be expressed as a string literal (e.g. x:DataType="local:MyType").

In Xamarin.Forms 4.3, while you can still express your compiled binding as a string literal, you can also express it using the x:Type markup extension (e.g. x:DataType="{x:Type local:MyType}").

But they 'worked' perfectly well for us. They provided us with Intellisense support in data templates and our XAML compiled and our apps ran. This change either locks us out of updating Xamarin Forms until 4.3 is released or requires us to change over a dozen pages, live without Intellisense for who knows how long then change them all back when 4.3 is released.

Your reply appears to show no consideration for the nuisance you've caused some of your customers with this (from our point of view) pointless change.

Agree. This is literally the only reason why are still on XForms 4.0.
Waiting for 4.3

Was this page helpful?
0 / 5 - 0 ratings