Cannot get Xamarin Xaml Intellisense working in VS 2015

13,917

Solution 1

I resolved this issue by doing a simple workaround and here is the solution.

Right-click the XAML file in the Solution Explorer and select

Solution 1: "Open With... > Source Code (Text) Editor".

and in another time this also worked for me:

Solution 2: "Open With... > Source Code (Text) Editor with Encoding"

This workaround gave me the desired XAML IntelliSense even without installing the extra "Enable XAML Language for Xamarin.Forms" extension and even with ReSharper installed but suspended.

Solution 2

Extensions > Tools > Enable XAML Language for Xamarin.Forms

Enable XAML Language for Xamarin.Forms

Enables the VS built-in XAML language service to provide editing and intellisense for Xamarin.Forms XAML files.

https://visualstudiogallery.msdn.microsoft.com/8195a8e2-a842-4389-a8cb-34e4672e2e13

Update:

From @Jeff:

Seems I had to completely uninstall Resharper, not just disable it. Then reinstall the "Enable XAML Language for Xamarin Forms extension".

Additional info:

http://www.cazzulino.com/enable-xaml-forms-intellisense.html

Xamarin XAML Enabled:

enter image description here

XML Enabled and thus no Xamarin XAML Intellisense:

enter image description here

Solution 3

The reason why Intellisense is not appear in editor is that Xamarin XAML is not opened as file with content type xaml but file with content type xml.
To open xamarin XAML file as file with content type xaml simply in solution explorer right click the xaml file and select Open With... In popup select "XAML Designer with Encoding" and click OK.


Solution below is if you edit Xamarin xaml as file with content type xml. But this solution is not correct, IntelliSense then not always correctly suggests.

To take advantage of Intellisense the Visual Studio must get appropriate definition of xml namespace for Xamarin.Forms. For the Xamarin.Forms Visual Studio needs xml definition for namespace http://xamarin.com/schemas/2014/forms.
This definition can be provided to Visual Studio by two ways:

  1. You can use xsd file and this file then register to xml schemas - after you open xaml file, the menu Xml/Schemas appear.
  2. You can this definition create by assembly attribute XmlnsDefinitionAttribute. This attribute you can found in Portable.Xaml nuget package.

Suitable for Xamarin.Forms is the second way(using attribute).

If you use Xaml in portable library, restore(download and install) this nuget package to this library.
If you use shared project, then restore this nuget package to all projects referencing this shared project.

Then insert this attribute to appropriate place. I believe that the App.xaml.cs(if you use generated name App) is a good place. The code could look like this:

using Portable.Xaml.Markup;
using Xamarin.Forms;

[assembly: XmlnsDefinition("http://xamarin.com/schemas/2014/forms", "Xamarin.Forms")]

namespace YourAppNamespace
{
    public partial class App : Application
    {
        public App ()
        {
            this.MainPage = new MainPage();
        }
    }
}

And the rebuild solution, as I believe, might not be necessary to work Intellisense for Xamarin.Forms.

Solution 4

This worked for me:

right click on .xaml file and then select "Open With.." and select "XAML Designer" and also "Set as Default" then intellisense worked great.

enter image description here

Solution 5

I install the Extension Enable XAML Language for Xamarin.Forms from

Enable XAML Language for Xamarin.Forms

Still the intellisense was not working. I just need to close all tabs and close the visual studio. After re-starting Visual studio I open solution and XAML file. The instellisense is working fine.

Share:
13,917
Jeff
Author by

Jeff

Updated on July 21, 2022

Comments

  • Jeff
    Jeff almost 2 years

    I've been trying to get intellisense working for quite some time now, and am unable to see anything outside of

    !
    ![CDATA[
    ?
    
    • Visual Studio 2015 Update 2
    • Resharper is installed but disabled
    • Referencing the latest pre-releases of Xamarin Forms (2.3.0.38-pre2)
    • Xamarin for Visual Studio (4.2.21)
    • Portable project referencing the proper 2.3.0.38-pre2 targets file from NuGet
    • Enable XAML Language for Xamarin.Forms

    What else am I missing? I feel like it shouldn't be this difficult.

  • Jeff
    Jeff almost 8 years
    I apparently have that installed as well, forgot to list it. This does not help either.
  • SushiHangover
    SushiHangover almost 8 years
    @Jeff See my updates, are your <?xml version... highlighted red or black?
  • Jeff
    Jeff almost 8 years
    At the bottom of that article in the comments others are stating it doesn't work with Update 2.
  • SushiHangover
    SushiHangover almost 8 years
    @Jeff Working fine for us, maybe it was due to having it already installed working before the upgrade? Also did a bunch of fresh workstation images this past weekend to push out, fresh Win10, plus all the goodies, they are working fine in this regard....
  • Jeff
    Jeff almost 8 years
    I reinstalled it but with it enabled and disabled it looks like image 2. Not sure what the deal is here. i.imgur.com/iehWruv.png
  • Jeff
    Jeff almost 8 years
    Thanks for your help @SushiHangover, posted what I ended up having to do above.
  • c0bra
    c0bra almost 8 years
    Update: I was not on latest Xamarin release.
  • Brian
    Brian over 7 years
    I've also experienced the same problem recently, I'm unsure if it's the Xamarin or Visual Studio update, anyhow, this solution works perfectly! Intellisense is working again, thanks :)
  • EdC
    EdC over 7 years
    As per this answer, restarting alone and reloading the project was not enough. I too had to close the XAML files explicitly and reopen them.
  • SeanH
    SeanH about 7 years
    Looks like the link to the extension is dead as of this comment
  • A.T.
    A.T. about 7 years
    this works for me, all I need to do is; after setting above settings I close all files and restart VS. thanks :)
  • bryanbcook
    bryanbcook about 7 years
    I'm using Visual Studio 2015 Update 3, no Resharper, latest Xamarin.Forms - this worked without having to install anything. Would not have thought Source Code (Text) Editor with Encoding.
  • Gravity
    Gravity over 6 years
    does this problem still persist?
  • Admin
    Admin over 6 years
    You cannot use the XAML Designer with Xamarin, only WPF XAML.
  • Stefan Babos
    Stefan Babos about 6 years
    I didn't claim anywhere I wanted to use XAML Designer with Xamarin! When I chose the menu "XAML Designer with Encoding", so I then did not use the designer (that I minimized). I used only coding.
  • Admin
    Admin about 6 years
    The XAML Designer code editor's intellisense is for WPF, not Xamarin so would no use editing Xamarin Forms XAML due to a large difference in tags and syntax. So my original statement is correct.
  • Stefan Babos
    Stefan Babos about 6 years
    You're right, but not entirely. When create WPF, the XAML begins, for example: <UserControl x:Class="..." xmlns="schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="schemas.openxmlformats.org/markup-compatibility/20‌​06" With Xamarin XAML begins: <ContentPage xmlns="xamarin.com/schemas/2014/forms" xmlns:x="schemas.microsoft.com/winfx/2009/xaml" x:Class="XamlSamples.MainPage"> So when the XAML interprets namespaces, it can edit it.
  • Emil
    Emil over 5 years
    best solution. no need to install any extension. Only you need to indicate that "right click on a xaml file on the solution explorer, not on windows explorer"
  • Emil
    Emil about 5 years
    we are on Vs 2019 after 5 years and this problem still exist. shame on you microsoft. instead of making collectionview and other things, concentrate on big things