xamarin/Xamarin.Forms

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

開放

#7,698 建立於 2019年9月26日

 (2 則留言) (0 個反應) (1 位負責人)C# (1,926 個分叉)batch import
a/Xaml </>a/binding ⛓e/5 :clock5:help wantedt/bug :bug:up-for-grabs

倉庫指標

星標
 (5,644 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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

貢獻者指南