Xamarin.Forms - InitializeComponent doesn't exist when creating a new page

前端 未结 30 2276
不知归路
不知归路 2021-01-30 12:36

I\'m using Visual Studio to try out Xamarin.Forms. I\'m trying to follow the guide: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/xaml-for-xamarin-forms/getti

相关标签:
30条回答
  • 2021-01-30 13:11
    1. Select the App.xaml and MainPage.xaml file of the class in which the issue is present.
    2. Right click and select properties.
    3. In Build action select "Embedded Resource"
    4. In Custom Tool type "MSBuild:UpdateDesignTimeXaml"
    5. Clean and Build and it was gone.
    0 讨论(0)
  • 2021-01-30 13:12

    I have met this problem. It's associated with the encoding of XAML files in VS. I'm using VS2015.

    I solved this problem as follows:

    1. Open the *.xaml file in the project and click Save button. (There will be applying the correct encoding in VS2015).

    2. Then reopen the project and rebuild it. Now there are no errors.

    0 讨论(0)
  • 2021-01-30 13:12

    A Clean and rebuild did the trick for me!

    0 讨论(0)
  • 2021-01-30 13:13

    Right click *.xaml and click properties,and change "Custom Tool" value to "MSBuild:UpdateDesignTimeXaml", next change "Build Action" properties to "Embedded Resource", build project works.

    0 讨论(0)
  • 2021-01-30 13:13

    Very simple solution that worked for me:

    • Copy contents of the xaml/cs file
    • Delete the xaml/cs file
    • Create a new class and paste the contents

    Now the InitializeComponent() function appears without red underline.

    Hope this helps someone.

    0 讨论(0)
  • 2021-01-30 13:13

    In my case the problem was the project path. The generated code file gets a name including the absolute path encoded to make it a valid filename. The path was "D:\Projekt C#\ProjectRootFolder\Project". The filename generated by the build tool was "Project.Droid.D_.Projekt_C_. Namespace etc." Moving the project to a path like "D:\project\ProjectRootFolder" helped in my case.

    0 讨论(0)
提交回复
热议问题