Visual Studio Intellisense not working on XAML only on very specific circumstances
Asked Answered
B

11

13

I'm making a new UserControl, and when I opened it the XAML was not working.

I thought that this was odd, as when I was working on my MainWindow it was working just fine. So I checked on my MainWindow. It still works there. Also in C# code.

However, if I press CTRL +        it still comes up fine.

I'm not quite sure why. I went to Tools➾Options➾Text Editor➾XAML➾General, and the Text Completion section is greyed out (e.g. Auto-List Members, etc.). This is also greyed out when I see it on my main window, but Intellisense works there.


Could someone help me? My VS version is VS2012 Express, Update 2. The only extension installed is XNA (using this "hack").

Blocker answered 10/6, 2013 at 7:38 Comment(1)
nothing's wrong with the question, so +1, people should leave comments when they do that. Thanks for the tip on installing VS2012 Update 2, I hope it will fix my XAML IntelliSense too.Herrin
B
8

Huh. I just restarted it and it worked again. The problem is that before, when I restarted it, it still did not work. I haven't found the underlying issue, but it's fixed now.

Blocker answered 10/6, 2013 at 10:31 Comment(0)
B
10

This is one of the most frustrating things about developing wpf apps I have to say. And here is a temporary solution that was observed by chance and works every single time intellisense breaks while working with XAMl:

  • Break the xaml file by any means; ex: removing any char/symbol

  • Hit F6 to build

Done and intellisense is back in couple seconds!

Burgas answered 3/12, 2015 at 16:33 Comment(2)
Just had this problem in VS2012, and after restarting VS and my machine, as well as clear out my SUO and multiple clean/rebuilds, I still didnt have intellisense. I removed a closing > on a single element, tried to build (and got an error) and after putting it back, my intellisense works again. Great solution, and definitely worth trying before anything more complicated.Lateritious
This workaround no longer seems to work in VS2019, now the only workaround (which also worked in older VSs) is to change build from Debug to Release and back.Fibro
B
8

Huh. I just restarted it and it worked again. The problem is that before, when I restarted it, it still did not work. I haven't found the underlying issue, but it's fixed now.

Blocker answered 10/6, 2013 at 10:31 Comment(0)
U
5

There are several reasons why Intellisense may fail and if you have several factors in play you will have to do several things to get it to work and so I've listed some of the things that I've done to solve this issue in the past.

Make sure you are using either the XAML UI Designer or the Source Code (Text)Editor for editing XAML with Intellisense. The XML (Text) editor does not provide Intellisense on my installation (VS2013 Pro).

If the designer crashes due to an exception in a loaded assembly you may also lose Intellisense. Fix the exception to restore it.

The designer may not load correctly if an assembly in your project is not trusted and has been sandboxed, and this can affect Intellisense.

See the following articles for more information on sandboxing and granting full trust:-

http://msdn.microsoft.com/en-us/library/dd409252(VS.100).aspx

http://msdn.microsoft.com/en-us/library/ee890038(v=vs.110).aspx

Obviously only grant full trust to assemblies that you trust!

To grant full trust to an assembly, browse to the assembly in Windows Explorer and open the file properties and unblock the assembly (see image below).

enter image description here

Also, deleting .suo files can clear intermittent Intellisense problems.

Unstep answered 25/9, 2014 at 15:59 Comment(1)
So frustrating. changed the default editor to XML so I don't get the annoying designer. as you suggested setting it to Text editor solved the problem.Dentate
A
3

In my case, IntelliSense would not work at all on MAUI XAML files. The issue was ReSharper trying to override the default Visual Studio IntelliSense for XAML files.

In order to fix it, I followed this approach:

Extensions > ReSharper > Options

In the Options dialog go to Environment > IntelliSense > General

I selected Custom IntelliSense, enabled ReSharper IntelliSense on C# files and set Visual Studio on XAML (.xaml files). This option prevents ReSharper from injecting its custom IntelliSense to XAML files. Instead, it lets Visual Studio pop up its own.

This is what fixed it for me on Visual Studio 2022 Enterprise.

Acetyl answered 8/9, 2022 at 5:53 Comment(0)
K
1

In my case, Tools / Options / Text Editor / XAML / Miscellaneous / Always open documents in full XAML view was Unchecked. After checking it and re-opening my XAML file from Solution Explorer, I had intellisence back.

This happened in Visual Studio 2013.

Kaylenekayley answered 21/9, 2015 at 15:9 Comment(0)
I
1

In my case setting the Properties (F4) > Build Action of the *.XAML to Page fixed IntelliSense.

Idol answered 2/12, 2018 at 10:2 Comment(0)
P
1

In Visual Studio 2019, switching and building between Release and Debug modes brought it back.


💡 x:Class out of Sync 💡

One other thing I noticed was that in the editor file of my user control, the x:Class="..." was second in line before another namespace.

By putting the x:Class as the first namespace for the control, brought back intelisense.

Provide answered 20/1, 2020 at 19:33 Comment(1)
This one works perfectly in VS2022Kolb
C
0

I got the same issue after uninstalling Resharper from VS2019. In the options dialog the "auto list members" and related options for Text Editor->XAML was disabled.

I tried to reset the default editor for XAML to Source Code Text Editor by clicking Open With... on a XAML file, did not work.

I then tried to update and even reinstall VS, nothing worked.

In pure desperation I went back to the same options page as "auto list members" and disabled and then re-enabled any property ("Line Numbers" i my case). This seemed to light a spark and now it's all good again.

Criseyde answered 18/2, 2020 at 7:23 Comment(0)
K
0

​In my case, the solution to the IntelliSense on Xamarin XAML files was tied to NuGet package references, I think especially the Xamarin.Forms package. If you have the yellow warning symbol on your packages, you have to get through the following steps on your specific project: ​ ​- Make sure it builds without errors

  • Pass a msbuild /restore [path to the specific project] ​ ​- Pass a .\nuget restore at your solution

  • Close and reopen your solution

  • Right-click on the concerned XAML file > Open With... > Make sure to have"XAML Designer" or "Xamarin.Forms Previewer" set to default for XAML files

You should now have IntelliSense.

​ ​In my case, that made the yellow warnings disappear, then XAML IntelliSense worked again on Xamarin.Forms files

Kingston answered 9/4, 2020 at 14:28 Comment(0)
M
0

Try building the project and deploying the project. There may be error in some dll or in some C# code. Try fixing all the errors in your C# code, after that dll errors will be automatically fixed. Now Code Completion and Intellisense should work in XAML. If not try Clean-Build the solution again. If no errors are encountered, XAML Code Completion and Intellisense will work.

Muncy answered 29/6, 2020 at 11:25 Comment(0)
F
0

My IntelliSense was also not wokring on some .xaml files. Then I found out I defined both:

<Window.DataContext>
    <core:MyDataContext/>
</Window.DataContext>

and

<Window x:Class="Namespace.MyWindow"
        ...
        mc:Ignorable="d"
        d:DataContext="{d:DesignInstance Type=core:MyDataContext}">

Removing the one I figured was not necessary fixed it.

Flanders answered 2/9, 2020 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.