InitializeComponent does not exist in the current context

2

I have this code, where I have the error

[XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class AprovarPopup : PopupPage
    {
        public AprovarPopup()
        {
            InitializeComponent();
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();
        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
        }

        // Method for animation child in PopupPage
        // Invoced after custom animation end
        protected override Task OnAppearingAnimationEnd()
        {
            return Content.FadeTo(0.5);
        }

        // Method for animation child in PopupPage
        // Invoked before custom animation begin
        protected override Task OnDisappearingAnimationBegin()
        {
            return Content.FadeTo(1);
        }

        protected override bool OnBackButtonPressed()
        {
            // Prevent hide popup
            //return base.OnBackButtonPressed();
            return true;
        }

        // Invoced when background is clicked
        protected override bool OnBackgroundClicked()
        {
            // Return default value - CloseWhenBackgroundIsClicked
            return base.OnBackgroundClicked();
        }
    }

and this is my xaml

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
             xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
             x:Class="Demo.Pages.AprovarPopup">
    <!--Animations use example-->
    <pages:PopupPage.Animation>
        <animations:ScaleAnimation 
      PositionIn="Center"
      PositionOut="Center"
      ScaleIn="1.2"
      ScaleOut="0.8"
      DurationIn="400"
      DurationOut="300"
      EasingIn="SinOut"
      EasingOut="SinIn"
      HasBackgroundAnimation="True"/>
    </pages:PopupPage.Animation>
    <!-- Content -->
</pages:PopupPage>

in this link there is a probable answer, but I did not understand the question of "Build Action" and also if my x: Class is correct.

EDIT1

I changed the "build action" of both xaml and xaml.cs and switched to > Page , the InitializeComponent error occurred, but triggered this:

  

The 'Page' compilation action is not supported by the combination   specific destination   project. Authorization C: \ Labs \ Authorizer \ Authorizer \ Authorizer \ ApprovePopup.xaml 0

EDIT2

I solved with a Clean and Recompile. I have observed in my few months with the tool Xamarin.Forms a lot I solved with Clean and Recompile. I saw that cleaning is almost everything, eheheh. The problem is solved. I'll leave it that way, I promised that when I made a post and then the solution, I would not respond, not to think that I'm trying to "defraud". It's an edition.

    
asked by anonymous 31.10.2017 / 09:55

1 answer

0

Close the visual studio and the emulator, go to C: \ Users \ SEU_USUARIO \ AppData \ Local and remove the folder xamarin, open visual studio again and your app will compile normally

    
16.10.2018 / 22:36