Reputation: 335
All the tutorials and web pages talk about using Project|Add New Item and adding a new "Forms Xaml Page". But whenever I install Xamarin and Visual Studio 2015, I just get the "Forms ContentPage" and "Forms ContentView" which just generate a C# file, no Xaml.
I have tried this and it didnt work.
And I've also tried reinstalling Visual Studio. Does anyone have a clue what to do?
The real problem is that I want to keep the Xaml with the code-behind file together, like
Upvotes: 4
Views: 2876
Reputation: 1
I think you can use the content page, it has the .xaml extension and comes with the code behind. They just change the name of the template.
Upvotes: 0
Reputation: 11
I just did a clean install of Visual Studio 2017 and the "Forms Content Page Xaml" showed up in Add New Item dialog. Which items you chose when installing the Xamarin for Visual Studio pack? Compare with the ones I've selected. Maybe something was left unchecked?
Also, if you want to keep the Xaml file together with the code-behind file, there's a way to do it by editing the YourProjectName.projitems inside your project folder. To find it, right-click the your main project and open its folder in the Windows Explorer, and then use a file editor to edit the .projitems file. Search for the Compile tag for the .cs files you want and add the DependentUpon tag inside it, just like in the example below:
<Compile Include="$(MSBuildThisFileDirectory)YourFile.xaml.cs">
<DependentUpon>YourFile.xaml</DependentUpon>
</Compile>
After doing this, unload and reload your project. Unfortunatelly I've had to do this procedure to all the new Xaml files I've created on my projects.
Upvotes: 1