title: Getting error: "The name InitializeComponent does not exist in the current context", in every xaml.cs class (Xamarin Forms)
body: <p>So suddenly the common error &quot;The name InitializeComponent does not exist in the current context&quot; appeared in every single xaml.cs class in all my solution, I have tried multiple common solutions to this issue but none of them seems to work.</p>
  <p>A xaml.cs inheriting a Content view:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using Xamarin.Forms;
  
  namespace FirstApp.Renderers
  {
      public partial class CustomExpansibleMenu : ContentView
      {
          public CustomExpansibleMenu()
          {
  //Error here
              InitializeComponent();
          }
      }
  }
  </code></pre>
  <p>A xaml.cs inheriting from a Content Page:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Threading.Tasks;
  using FirstApp.Services;
  using Xamarin.Essentials;
  using Xamarin.Forms;
  
  namespace FirstApp.Pages
  {
      public partial class ChatMenuPage : ContentPage
      {
          private NavigationService navigation;
          public static double numPixelsW;
          public static double numPixelsH;
  
          public ChatMenuPage()
          {
              numPixelsH = DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density;
              numPixelsW = DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density;
  
              navigation = new NavigationService();
  
  //Error here 
              InitializeComponent();
  
  //Another error here, searchBox is the name of a frame in my xaml page, but //I cant access to it because of the previous error
              searchBox.BorderWith = 3;
          }
      }
  }
  </code></pre>
  <p>These are the common solutions that I have tried:</p>
  <ol>
  <li>Verify that the xaml´s buildActions are set to EmbeddedResource
  2)Verify that the namespace in xaml and xaml.cs are the same.</li>
  <li>In the xaml verify that Custom Tool: MSBuild:UpdateDesignTimeXaml</li>
  </ol>