I want to know why we can't put in a class C # with Xamarin.forms "BindingContext = this" but we can do it in a content page (class and .Xaml) ?
Can You provide any sample of this ?
If you do MVVM BindingContext is used to bind your view-model class to your Layout.
BindingContext is a property of BindableObject, and ContentPage is inherit from BindableObject. So you can use the BindingContext in a content page . (ps : you can check the Inheritance relationship by clicking the class ContentPage step by step)
Besides , ordinary classes do not have this property,so we can't put it in a class .
ContentPage is inherited from TemplatPage, TemplatePage is inherited from Page and so on. If you inherit your ordinary class eg. Class.cs with ContentPage then you will be able to use BindingContext.
BindingContext is property to help you deal with data bindings. Some common case is usage of BindingContext when you are developing in MVVM pattern.
Take a look: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/enterprise-application-patterns/mvvm
Take look here : https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.bindableobject.bindingcontext?view=xamarin-forms#Xamarin_Forms_BindableObject_BindingContext
hope it helps,
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies