Compiled bindings in Xamarin Forms

Is this enough to make it use compiled bindings? Or do I also have to set the x:DataType on the layout element as well?

The process for using compiled bindings is to:

Enable XAML compilation. For more information about XAML compilation.

Set an x:DataType attribute on a VisualElement to the type of the object that the VisualElement and its children will bind to.

Binding expressions are only compiled for the view hierarchy that the x:DataType attribute is defined on. Conversely, any views in a hierarchy on which the x:DataType attribute is not defined will use classic bindings.

So your code is classic bindings, the following code is complied bindings:

    <Grid x:DataType="vm:AddParkingSpotViewModel">
            <vm:AddParkingSpotViewModel />
        <Entry Text="{Binding Address}" />

More detailed info about complied bindings, please take a look:

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top