Search code examples
xamlmaui

Is it possible to opt out of the validation provided by x:DataType?


So say an element declares an x:DataType, then any invalid binding is a compiler error. If, in some contexts, this isn't wanted, is it possible to discard the protections provided by an outer x:DataType?

I've considered/tried setting x:DataType to "" and "x:Object", however neither worked ("" is invalid syntax and x:Object doesn't seem to be a special case, still resulting in XFC0045 "Binding: Property "Xyz" not found on "System.Object"").

I recognise that (a) the easiest solution would be "don't use x:DataType at all!" and (b) if I'm already using x:DataType in some places, I may as well use it in all places, however I do believe that discarding x:DataType's protections is the best option if possible given the restrictions I'm trying to work within.


Solution

  • Thanks to Gerald Versluis for this answer in the comments - this can be achieved by setting x:DataType={x:Null}.