I have a problem. I created a CollectionView with a Label as a counter on each row and a button. What I want is that when I push the button, the label value will go up by +1, depending on the row you click. I already created the button event like this:
private void btnPlus_Clicked(object sender, EventArgs e)
{
int currentValue = Convert.ToInt32(txtCounter.Text);
txtCounter.Text = (currentValue + 1).ToString();
}
And here is my xaml:
<CollectionView ItemsSource="{Binding imageList}">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout HorizontalOptions="Center"
<Label Text="1" TextColor="Black" x:Name="txtCounter" FontAttributes="Bold" VerticalOptions="Center"/>
<Button CornerRadius="13" WidthRequest="25" Text="+" Padding="0"
HeightRequest="25" VerticalOptions="Center" Clicked="btnPlus_Clicked" />
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
But txtCounter
doesn't get recognized!?
What am I doing wrong?