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
UPDATE: This error doesn't usually appear in VS 2015, if it does, here's my original answer:
Found the solution! Right click on the .XAML file, select Properties.
You will see a Property called Custom Tool. Change its value from MSBuild:Compile
to MSBuild:UpdateDesignTimeXaml
This will solve the problem. Dont know about the downvote, but here's my screenshot:
UPDATE:
It reappears rarely. If it does, just open the Xaml and code behind files and save them. I know, its not the best solution, but it gets the job done.
This is probably not your case but I had similar problem and mine was xaml and code behind name missmatching. for example according to your sample, if code behind namespace is XamaTest(name of your app in most cases) and class is called MyXamlPage, your xaml class name must be XamaTest.MyXamlPage ([namespace].[classname])
I was silly after creating an empty xaml with code behind, I changed name of the class in xaml and i was getting this error.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamaTest.MyXamlPage">
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
</ContentPage>
Code-behind:
public partial class MyXamlPage : ContentPage
Check the version of Xamarin.Forms package referenced in your project.
In Xaml Page Properties only set
Build Action = Embedded resource
It works in visual studio 2017.
Visual Studio 2013
update 4 environment and I tried all recommendations what I found on the web. Nothing solved my problem. Visual Studio 2015
preview and create new blank app with xamarin forms project. Xaml
file everything was OK and issue with InitialComponent
method disappeared. I came across this error when;
ContentPage-cs+xaml
and the App-cs+xaml
from the project without actually deleting it. This was fixed by;
.xaml
file of the class in which the issue is present.properties
.Build action
select "Embedded Resource"Custom Tool
type "MSBuild:UpdateDesignTimeXaml"