Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

XAML - Change Label Text inside Viewcell from code behind

$
0
0

Hi everybody,
I need to change a label text put into a Viewcell from codebehind but I receive an error dispayng "the name likecount does not exist in the current context".

I want to show the label value initially(like count), it is working.

  <ListView x:Name="ListView1"  RowHeight="500">
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>

        <Label 
            Text="{Binding likeCount}"
            x:Name="likecount" 
            Font="14" 
            TextColor="Black"
            HorizontalOptions="Start" 
            VerticalOptions="Center"/>  

                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

After like or unlike i want to change the label text(like count). For that i use the following code:

If(like){
 likecount.Text = item.likeCount + 1;
 } else{
 likecount.Text = item.likeCount - 1;
 }

Currently showing, The name likecount does not exist in the current context.

Can you show how you create the datamodel?

Please help me, Thanks in advance.


Viewing all articles
Browse latest Browse all 204402

Trending Articles