Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

{Binding .} in Xamarin

I saw this piece of code in an example of some Xamarin code:

        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Label Text="{Binding .}" TextColor="#66ffff" FontSize="Micro" HorizontalOptions="CenterAndExpand" />
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>

What does Binding . mean? My guess from trying out the code is one character from the ItemsSource like in a regular expression? But I can't find this in the documentation.

like image 726
Lavandysh Avatar asked Mar 05 '26 20:03

Lavandysh


1 Answers

The point (.) means that you bind the whole object/ model instead of a single property to the text property of that label. This is sometimes required, for example you need multiple aspects from your model in a converter.

In this code example above, it also could be that the item source for that listview is a list of strings. So there is no property to bind to the text property.

like image 173
tequila slammer Avatar answered Mar 08 '26 19:03

tequila slammer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!