Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection between .xaml and .xaml.cs files are being lost every time I move or add new file

Tags:

xaml

xamarin

I just installed VS2015 with Xamarin on windows and I followed the Quick guide: https://developer.xamarin.com/guides/xamarin-forms/getting-started/hello-xamarin-forms/quickstart/

At first the .xaml.cs file had a lot of errors in InitializeComponent() and every other reference to the items on the .xaml file like the Buttons and Entry as if they could not be found.

I thought it was a namespace problem and the two files were not aware of each other, and after trying many things I changed the "Class" attribute in the .xaml file, saved it and after realizing that it didn't solve the problem, I changed it back to the original name space x:Class="Phoneword.MainPage" and after saving, all the errors were gone.

Yay! I was happy, I thought it was just a first build problem, but now every time I move a file or create a new one, I have the same problem. Even when I create just a resource file inside a different directory. Every time, the only fix is to do the same procedure I just described.

It also happens when cleaning the project.

Really annoying and I don't know what's going to happen when I have more xaml files.

Any idea how to fix or why it is happening?

Thanks

like image 940
Dpedrinha Avatar asked Dec 08 '25 16:12

Dpedrinha


1 Answers

Any idea how to fix or why it is happening?

As a workaround, at the moment, you can manually edit the .csproj to keep the connection between XAML and designer file.

For example:

<Compile Include="Pages\QuestionPage.xaml.cs">
  <DependentUpon>QuestionPage.xaml</DependentUpon>
</Compile>

I would recommend filling a bug at https://bugzilla.xamarin.com/newbug

like image 78
Prashant Cholachagudda Avatar answered Dec 11 '25 17:12

Prashant Cholachagudda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!