Error during Page Deletion - Xamarin

Asked

Viewed 54 times

1

I’m new to mobile programming, so I wanted a help to treat an error that seems not set by the IDE (Visual Studio).

The case is that I have a screen that wanted to insert that carousel with promotional cards (something similar to the google store homepage). Here is that during the tests, the VS does not error in the code but in the compilation appears the problem.

I put an image with error print. Thank you all!


XAML :

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             
             x:Class="JetSolutionsApp.Views.Aba.Parceiros">

        <StackLayout>
        <CarouselView x:Name="slideTopo">
            <CarouselView.ItemTemplate>
                <DataTemplate>
                    <Label Text="{Binding .}"
                           FontSize="50"/>
                </DataTemplate>                
            </CarouselView.ItemTemplate>
        </CarouselView>
    </StackLayout>   
</ContentPage>

Code :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace JetSolutionsApp.Views.Aba
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Parceiros : ContentPage
    {
        public Parceiros()
        {
            InitializeComponent();

              var nomesCarousel = new List<string>
              {
                  "jose"," maria", "joaquim", "joão"
              };
            slideTopo.ItemsSource = nomesCarousel;

        }
    }
}

This is the mistake:

Erro

  • Try to use <Label Text="{Binding}" ="50"/>

1 answer

1

Try changing the XAML of CarouselView to the following:

<CarouselView x:Name="slideTopo" ItemsSource="{Binding .}">
    <CarouselView.ItemTemplate>
        <DataTemplate>
            <Label Text="{Binding}" FontSize="50"/>
        </DataTemplate>   
    </CarouselView.ItemTemplate>
</CarouselView>

If the above solution doesn’t work, we can try another way:

C#

namespace JetSolutionsApp.Views.Aba
{
    internal List<string> Nomes { get; set; }

    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Parceiros : ContentPage
    {
        public Parceiros()
        {
            InitializeComponent();

            Nomes = new List<string>()
            {
                "josé",
                "maria",
                "joaquim",
                "joão" 
            };

            slideTopo.ItemsSource = Nomes;
        }
    }
}

XAML

<CarouselView x:Name="slideTopo" ItemsSource="{Binding Nomes}">
    <CarouselView.ItemTemplate>
        <DataTemplate>
            <Label Text="{Binding .}" FontSize="50"/>
        </DataTemplate>   
    </CarouselView.ItemTemplate>
</CarouselView>
  • Good evening John, I experienced the change you suggested but the error remains. I searched for coding errors but there’s nothing, just this flaw.

  • Edited response.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.