Improve information/experience around x:DataType behaviour in Debug vs Release #21735
Labels
area-xaml
XAML, CSS, Triggers, Behaviors
fixed-in-8.0.80
fixed-in-9.0.0-preview.7.24407.4
t/bug
Something isn't working
Milestone
Description
There can be differences in behaviour at runtime in Debug vs Release builds and using
x:DataType
.For example, take the following view models (Note that they both have a
Text
property):Now with the following XAML:
If we set the binding context in the page's code behind:
Everything compiles fine. In a Debug build, the label shows the expected text
Wrong Value
despite the incorrect type on the instance assigned to the Binding context.If you run a Release build however, the label has no text. Presumably the type cast fails at runtime as the instance assigned to the binding context does not match the
x:DataType
specified for this compiled binding, and this does not happen in Debug because there's no XAMLC step and so all the bindings are dynamic.How do we improve the experience here?
Possibly related / duplicate:
The text was updated successfully, but these errors were encountered: