Forms Xaml Page missing in Visual Studio 2017 Xamarin - c#

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

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.

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.

Related

why is Intellisense not working in my VS Code?

I am working on vs code. When I open any folder the IntelliSense is not working when I hover the mouse over any text. It was working before but now I don't know why it's not working. Kindly help...
Solution 1 :
Ctrl+Shift+P
Write "OmniSharp: Select Project" and press Enter.
Choose the solution workspace entry.
Then enable the C# extension for "OmniSharp : Project"
Solution 2 :
Selecting a project.json-file is opening a DNX-project and VSCode will load that project plus the referenced projects.
Selecting a *.sln-file is opening a MSBuild-project. It will load the referenced *.csproj-projects and sibling or descendant project.json-files but no other project files that are referenced from the solution file.
Selecting a folder will make VSCode scan for *.sln and project.json files and VSCode will attempt to load them all.
More info see: https://github.com/OmniSharp/omnisharp-vscode/issues/1889
Solution 3:
Download C# v1.24.0 extension can fix the IntelliSense for you
Solution 4:
For bootstrap and HTML IntelliSense, add the following extensions:
HTML HTML CSS Support
IntelliSense for CSS class names in HTML
NOTE :
All solutions need to close your VS and reopen it again.
For me solution 2 worked.
C# IntelliSense did not work with C# Extension v1.25.0.
Solution involved:
Download the old version of C# Extension 1.24.4 vsix
Install vsix manually to VS Code:
Open VS Code.
Open the “Extensions” sidebar (you can use
“Ctrl+Shift+X”).
Click on the ellipsis icon in the top right corner
of the menu.
Select “Install from VSIX…” VS Code will open a
document browser.
VS Code will now begin the installation
process of the extension.
This happened to me on 2 separate machines

vs 2017 intellisense not working C# and XAML

I have a Strange issue that I can't seem to fix, my Intellisense for XAML is no longer showing up and the code behind is only showing the premade Members. The Classes and Methods I have made are not showing up. Also Visual Studios is not recognizing other pages and wont recognize Navigation either.
I have tried going to Tools>Text Editor>C#>Intellisense -Statement completion and checking the boxes Auto list members and Parameter information. I also tried to clear out the cache.
From what I have researched it seems nobody else is having the same problems.
Close all open tabs in the project and quit VS, reopen the solution in VS and right click the XAML file in the Solution Explorer and then select Open With….> Source Code (Text) Editor.
Delete obj folder and clean project
Right click the XAML page>Properties>Build Action>change it to something else and back
Add a new content page under this specific project and check it works or not.
I would like to add that this worked for my .cs files only.
To get the XAML files Intellisense to work try to repeat the above steps on your .cs files or wait for the XAML files to gain Intellisense.
For ReSharper users: I found that having ReSharper's IntelliSense enabled for all languages can break Intellisense unexpectedly (especially for XAML files). Here's how I was able to fix the same problem that the asker had in Visual Studio 2017 with ReSharper installed:
In Visual Studio, go to the ReSharper menu and click on Options.
On the left side go to Environment > IntelliSense > General.
Select the Custom IntelliSense radio button.
Change any languages that have broken IntelliSense to Visual Studio (like XAML).
Click the Save button.
Just Exclude and Include Xaml Pages and It works again.
I solve that by changing the default editor in visual studio :
In Visual : File > Open
In the open file box : Select a .xaml file (don't open it)
Select "Open with" in the button arrow
Select "Source Code (Text) Editor and Set as Default
Click OK
I tried most of the above without much luck, but noticed if I created a new page, then intellisense worked as expected. For the properties section of the xaml file I noticed that the new page had a Custom Tool assigned (MSBuild:UpdateDesignTimeXaml) do I tried to cut-and-paste this into the existing forms without luck.
Looking at the .cs page for the new page that worked I notice that there is some extra info above the partial class [XamlCompilation(XamlCompilationOptions.Compile)] so I added this along with a using Xamarin.Forms.Xaml statement.
Finally I went back to the xaml properties page and selected Reset to Default for the Custom tool. Voila, for me everything started behaving itself.
Please add the following Nuget Package from Nuget Console.
Install-Package MobileEssentials.FormsIntellisense -Version 0.1.1-pre
You can download the latest update from the following link.
https://www.nuget.org/packages/MobileEssentials.FormsIntellisense/0.1.1-pre
After installing the package please restart the project and wait for sometime and check it.
Just delete .vs directory. this directory is hidden. so
Just Exclude and Include Xaml Pages worked for me too. The difference in .csproj file was:
MSBuild:Compile
now:
XamlIntelliSenseFileGenerator
I could fix the issue in VS2019 by launching the VS installer to modify it, un-check and check the workload ‘.NET desktop development’ to re-install it.

Unable to access 'Build Action' property for .cs files

i got a problem with my site with my app_code files and a lot of question ive read people say you need to change the proprties of the .cs files to Build Action.
by right clicking the .cs files and press proprties.
but...
when i right clicking the files i cant see any option called proprties so i press F4 and it open a proprties window and i just click on the .cs file and still cant see any option i can change somthing to Build Action.
any idea why i cant see this options?
EDIT:
my problem is that when i get in the file proprties i have only 2 options...
thay are called:
1.Full Name
2.Full Path
EDIT2:
here what i see in visual studio 2010 when i try access the protrtie menu/window
http://img338.imageshack.us/img338/2359/blac.png
As Microsoft points out in the article "Web Application Projects versus Web Site Projects":
Web application projects use Visual Studio project files (.csproj or
.vbproj) to keep track of information about the project. Among other
tasks, this makes it possible to specify which files are included in
or excluded from the project, and therefore which files are compiled
during a build.
An answer to a similiar question at CodeProject's forums reveals a hint. Abstract:
[...] Looks like you are working on a web application that is actually a
Website as per Visual Studio. You would need to create a new Web Application
and probably copy over the source files there. [...]
http://www.codeproject.com/Questions/173637/Setting-Build-Action-for-Files-in-App_Data
Have you tried this:
You say you haven't got the option being suggested by other posters.
If this is the case, than it is quite possible that your Visual Studio settings are corrupt; this can give rise to all sorts of odd behaviour.
I would suggest you reset your settings, but please be aware you will lose any custom IDE settings that you've previously applied.
Try this:
In Visual Studio, go to Tools->Import and Export Settings
Choose "Reset All Settings" and click Next
Choose to save your current settings if you wish, or select "no" and then click next.
Choose the collection of settings( he IDE preset) you want, probably "Visual C# Development Settings"
Visual Studio will now revert all settings. Hopefully this will make the Build Action reappear.
[EDIT]
It might be worth trying safe mode too.
To do this, start up a "Visual Studio Command Prompt" from your start menu/programs list in Windows, and start Visual Studio with
devenv.exe /SafeMode
Does this make the options appear?
You can copy the file from Windows Explorer and paste it in the Solution Explorer. It will replace (or do nothing but incorporating it in the proj file) the file and recognize it as C#.
Normally you should see a Property named "Build Action" in the first line of the Property Window. This property should be set to "Compile".
Please select file and right click on it so that you will get following screen
Than click on the Properties you will get following screen
You can find build option in as a first option.

Designer.cs gets corrupt after making changes to the webpage in Visual Studio 2010

Visual Studio isn't behaving normally when I make a change in an aspx file. It makes changes to the designer.cs file. These changes mean that I cannot access any of my controls by their ID in my code behind file.
When I revert the changes (using SVN), that have been made behind my back, in the designer.cs file, my build succeeds again and everything works fine.
I see that Visual Studio deletes a lot of lines in the designer file.
I've read some similar issues on the web but I can't find a good solution for this.
Has anyone of you experienced the same problems with Visual Studio and can help me solving this?
Update: I found that Visual Studio adds this line to the designer.cs:
protected global::System.Web.UI.WebControls.UpdatePanel UpdatePanel1;
But this should be:
protected global::System.Web.UI.UpdatePanel UpdatePanel1;
When I make this change manually in the designer.cs file, it works. But every time I make a change to the aspx file, Visual Studio creates again the wrong reference.
im having the same issue. my workaround is moving the definition from the designer file to the code behind file and defining it properly as:
Protected WithEvents UpdatePanel1 As Global.System.Web.UI.UpdatePanel
instead of letting designer keep overwriting it improperly as
Protected WithEvents UpdatePanel1 As Global.System.Web.UI.WebControls.UpdatePanel
im using vs2013 vb.net asp web forms application.
i've also seen suggestions to change the target framework in the web.config file to 4.0 (did not work for me, im targeting 4.5, was getting the problem with both targets)
and i also saw a suggestion to use the Register tag like:
<%# Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web"%>
at the top of the page. this did resolve the 'error' that was being thrown when i tested it, however it caused numerous 'warnings' to appear for all of my asp tags.
My office is plagued by this issue in Visual Studio 2013. We were using the following workaround:
Right-click on the project and select Properties.
On the Application tab, change the Target framework version and save the project.
Repeat steps 1 and 2 to set the target framework back to the one you want.
Save the .aspx file again.
This would work 100% of the time, but we discovered that it messed up some of our web.config settings.
We are now using the following workaround, which also seems to work and does not make any breaking changes to the project config files:
Right-click on the project and select Unload Project.
Right-click on the project and select Reload Project.
Save the .aspx file again.
Make sure that the class name of the cs file is the same as the designer.cs and check the Inherits attribute of the page in the aspx file is the same. Also check if there is any class in your project with the same name as your page class name, also i would like to know the error that appear when you make any updates in the aspx page.

adding images in my project

I'm trying to add/change images in my project, using Microsoft Visual Studio 2008 C#. Along with it, Devexpress components are also included.
What I did, I copied an image (.png file) and paste it it in my "PrintRibbonControllerResources.resx" and then after that I have to open again the MainForm.cs right click on the form and click on the Run Designer. It will open the Ribbon Control Designer. From there, I can add the image.
Do you think its ok? It's my first time to do this, and I don't have any experience & I'm learning it by doing.
Thanks
===
it seems I don't see the add function under resource tab
I generally add an image to the project itself. (Add/Existing item) I do this so I can use SourceControl to check in/out the image file. The resx then links to these files.
Basically, my philosophy is: if it works, don't fix it.
If this solution works for you, it's fine. At least, until you discover a situation where it fails.
If you go in the properties of your project, and select the resources tab, you can add it directly from there and it will be accessible in the default resource file of your project, which might be more convenient.
I like to add it to a solution folder (or folder in the project) and like that to the resx via "Add Exising File".
I get all of the advantages of having the resource file, but also the advantages of having a physical file (editing, quick view, etc.)

Categories

Resources