Page not found but the page exists

pnet1pnet1 USMember ✭✭✭✭
edited October 21 in Xamarin.Forms

In my xml i got this error

The Type or namespace name 'Sucesso' could not be found.

but i have this file in my project. I use Visual Studio for Mac and in this reference i have a symbol not identified. See image below

In the left botton i have something like a small icon. What happens this?
Below my xaml this page

<?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="PerformaMobile.Page.Sucesso">
    <ContentPage.Resources>
        <ResourceDictionary>

            <Style TargetType="Button">
                <Setter Property="BorderRadius" Value="5" />
                <Setter Property="TextColor" Value="White" />
                <Setter Property="BackgroundColor" Value="#78319A" />
            </Style>
            <Style TargetType="Entry">
                <Setter Property="TextColor" Value="#757575" />
                <Setter Property="FontSize" Value="Small" />
            </Style>
            <Style TargetType="Label">
                <Setter Property="TextColor" Value="#757575" />
                <Setter Property="FontSize" Value="Small" />
                <Setter Property="HorizontalTextAlignment" Value="Center" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.Content>
        <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="20">
            <StackLayout Orientation="Vertical" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand">
                <Image Source="ic_check.png" WidthRequest="100" HeightRequest="100" />
                <Label x:Name="successMessageTitle" FontSize="Large" FontAttributes="Bold" />
                <Label x:Name="successMessage" />
            </StackLayout>
            <Button x:Name="btnBack" Text="Voltar" Clicked="btnBack_Clicked"/>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>          

In the <Content... /> i get the error

My dev environment is: Visual Studio 2019 for Mac

Edit1

This is the Code of Sucesso.amxl.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

namespace PerformaMobile.Page
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Sucesso : ContentPage
    {
        public Sucesso(string title, string messageTitle, string message)
        {
            InitializeComponent();
            this.Title = title;

            successMessageTitle.IsVisible = !string.IsNullOrWhiteSpace(messageTitle);
            successMessageTitle.Text = messageTitle != null ? messageTitle : string.Empty;


            successMessage.IsVisible = !string.IsNullOrWhiteSpace(message);
            successMessage.Text = message != null ? message : string.Empty;
        }

        private void btnBack_Clicked(object sender, EventArgs e)
        {
            Core.App.Instance.ShowMainPage();
        }
    }
}

@igorkr_10 i posted the code above(Sucesso.axml.cs) and another page call this page this way.
await Navigation.PushAsync(new Sucesso("Ticket Cadastrado", messageTitle, message));

In this Line above i get this error message

The type or namespace name 'Sucesso' could not be found(Are you missing directive or an assembly reference?)

Tagged:

Answers

  • igorkr_10igorkr_10 Member ✭✭✭

    Show code of your page

  • pnet1pnet1 USMember ✭✭✭✭
    edited October 21

    In my resources file i put this Lines

    data name="Sucesso" xml:space="preserve"
             value>Sucesso</value
     /data
    

    but does not work

    p.s. i removed <> because was render and only Sucesso appear

  • LandLuLandLu Member, Xamarin Team Xamurai

    If you use the whole name with the namespace as the prefix will it work? Call it like:

    await Navigation.PushAsync(new PerformaMobile.Page.Sucesso("Ticket Cadastrado", messageTitle, message));
    

    Moreover, try to double click the code which threw the error. Then click Quick Fix. It will offer some options to fix this issue.

Sign In or Register to comment.