xamarin/Xamarin.Forms

[Bug] Compiled bindings to work when also Binding the BindingContext in XAML

Aperta

#7698 aperta il 26 set 2019

 (2 commenti) (0 reazioni) (1 assegnatario)C# (1926 fork)batch import
a/Xaml </>a/binding ⛓e/5 :clock5:help wantedt/bug :bug:up-for-grabs

Metriche repository

Star
 (5644 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Summary

Not sure if this a bug or a feature request.

When setting the BindingContext in XAML there is then no way to use compiled bindings.

For example

<custom:MyCustomView x:DataType="{x:Null}" BindingContext="{Binding PresenterViewModel}" IsVisible="{Binding IsVisible}" >
       <Label Text="{Binding Text}"/>
</custom:MyCustomView>

In the above code the datatype can only be Null

If you set it to any object, the two properties will conflict and say that either PresenterViewModel or IsVisible does not exist.

The bottom line is when ever you set BindingContext in Xaml, there is then no way to set DataType correctly

Guida contributor