Mireille
Mireille

Reputation: 677

Xamarin Forms Binding

Please can anyone tell what does "{Binding .}" mean? The point refers to what? I know that we have refer to a property but I don't understand when I have to put this point

Upvotes: 2

Views: 147

Answers (1)

Krumelur
Krumelur

Reputation: 33068

{Binding} in XAML is a markup extension, specifically, it's BindingExtension

If you look at this class, you'll see that it has a Path property. In XAML you use it like this:

{Binding Path=PathThePublicPropertyOfTheBindingContext} or, shorter by omitting Path=:

{Binding PathThePublicPropertyOfTheBindingContext}

If the object you want to bind to does not have a property you bind to, but you rather want to bind to the object itself, you use .. Say, your binding context is a string type:

public string MyObject = "Hello World";
BindingContext = MyObject;

and in XAML

<Label Text="{Binding .}">

it would display "Hello World", the content of the object itself.

Upvotes: 4

Related Questions