x:DataType 和 BindingContext 有什么区别
what is the difference between x:DataType and BindingContext
我在 xamarin.Form 页面上有这些值。他们两个都给了我智能感知。使用其中一个或两个的场景是什么?
<ContentPage x:DataType="vm:AboutViewModel" >
<ContentPage.BindingContext>
<vm:AboutViewModel>
</vm:AboutViewModel>
</ContentPage.BindingContext>
</ContentPage>
BindingContext
在运行时分配指定 class 的实例。
x:DataContext
是一个 设计时 助手,它告诉 Intellisense XAML 的给定块的上下文类型是什么
我在 xamarin.Form 页面上有这些值。他们两个都给了我智能感知。使用其中一个或两个的场景是什么?
<ContentPage x:DataType="vm:AboutViewModel" >
<ContentPage.BindingContext>
<vm:AboutViewModel>
</vm:AboutViewModel>
</ContentPage.BindingContext>
</ContentPage>
BindingContext
在运行时分配指定 class 的实例。
x:DataContext
是一个 设计时 助手,它告诉 Intellisense XAML 的给定块的上下文类型是什么