I had a VB projected and converted it to C# using online conversion tools. Now the problem is xaml
and xaml.cs
file do not connect to each other, t
Using Xamarin Shared Code solution:
1) Go to you project folder after unloading the shared project
2) Find the projitems file and edit that adding the DependentUpon tag as described in other answers above.
3) Save the file
4) Go back to visual studio and you should get a dialog that allows you to reload all or just open the project again.
If you cannot get the IDE to do it (Papa John's post), then you can do it by editing the project file.
That information is in the .csproj file (which is an XML file -- you can open it in a text editor, or by right-clicking on it, choosing "unload", and then opening it -- choose reload to load it up as a project again).
Here is the information to look for, you would need to add the "DependentUpon" tag.
<Compile Include="TheFile.xaml.cs">
<DependentUpon>TheFile.xaml</DependentUpon>
</Compile>
This is simple, try to add in project existing items and select the XAML (not .cs, etc.) files in list of formats. In VS2010 thats helps.
I was able to just restart Visual Studio for Mac 2019 v16.2 and it reconnected my .xaml & .cs files that should've been connected.
If that doesn't work, Hitsa's solution worked for me as well on a separate occasion.
The usual - Close Visual Studio, delete the vs folder in the root folder of your solution and reopen Visual Studio (2019) just worked for me.
An even easier and faster solution for Xamarin Forms projects, no need to touch csproj file at all, very quick fix.
Make sure you have Show All Files
selected for solution explorer - it may be on by default.
Exclude from Project
Include in Project
They should now all be nested correctly and all the changes necessary to the .csproj file will be done.
You may have an InitializeComponent() does not exist in the current context)
error after this.
If that's the case, the simple fix is..
Build Action
from Page
to Embedded Resource