locked
Intellisense prblem in xaml codes with detecting classes in a given namespace in VS2013

    Question

  • I am having a Win8 store app and developing VS2013. Frequently, I face problem with intellisense trying to detect the classes in the referenced projects.

    Let say I have a UserControl similar to this:

    <UserControl x:Class="MyNamespace.MyControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MyNamespace" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ViewModels="using:MyNamespace.ViewModels" xmlns:Converters="using:MyNamespace.ViewModels.ValueConverters" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="600" FontFamily="Global User Interface"> <UserControl.Resources> <Converters:MyConverter x:Key="MyConverter"/> </UserControl.Resources> <d:UserControl.DataContext> <ViewModels:MyViewModel /> </d:UserControl.DataContext>
    ...

    When I open the control in the Designer of VS, the intellisense gives the following error:

    The name "MyConverter" does not exist in the namespace "using:MyNamespace.ViewModels.ValueConverters".

    I have to note that all projects are build successfully and the control works at runtime. Also classes "MyConverter" and "MyViewModel" belong to a referenced project. The other point that I have to mention is that namespaces "MyNamespace.ViewModels" and "MyNamespace.ViewModels.ValueConverters" are shared across some projects and based on the intellisense it seems that it only searches one assembly and not all referenced assemblies having those namespaces. For example if I have these namespaces inside my Win8 store app project, intellisense does not search in the referenced assemblies otherwise if it finds it in one of the referenced ones, it does not search through other referred assemblies. As a result the designer does not show the control at all and gives "Invalid Markup" error.


    Monday, April 7, 2014 6:08 PM

All replies

  • Hi,

    Because this issue occured with the specific app: Windows Store app, I moved this thread to Building Windows Store apps with C# or VB forum for better support. Moreover VS General Question forum mainly discusses WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System and Visual Studio Editor.

    Thank you for your understanding.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 8, 2014 8:42 AM
  • I posted my question here because it seemed more like a VS Designer bug to me.
    Tuesday, April 8, 2014 4:14 PM
  • Hi Reza J,

    Well, I'm not sure how you structure your class in the project, for instance why you have such relation between ViewModels and ValueConvertor, shared across the projects? not understand.

    If you could provide some more information, for instance a reproducible demo or a more detail explanation would be much easier for us to identify if this is a WinRT issue or a Visual Studio question.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Wednesday, April 9, 2014 7:16 AM
    Moderator
  • Hi Jamles,

    There are some design reasons for why my solution is this way, you can assume that the Project1 sketched below is a third-party library and I want to add the ViewModels and Converters (coded in Project2) to the same namespaces as Project1.

    Here is how my app is designed:

    Project1 - (Class Library Windows Store):

    namespace MyNamespace.ViewModels
    {
    	class MyViewModel {}
    }
    namespace MyNamespace.ViewModels.ValueConverters
    {
    	class MyValueConverter {}
    }


    Project2 - (Windows Store App) which has a reference to Project1

    namespace MyNamespace.ViewModels
    {
        class MyOtherViewModel {}
    }

    namespace MyNamespace.ViewModels.ValueConverters
    {
        class MyOtherValueConverter {}
    }
    namespace MyNamespace
    {
        class MyControl {}
    }
    <UserControl
        x:Class="MyNamespace.MyControl"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:MyNamespace"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ViewModels="using:MyNamespace.ViewModels"
        xmlns:Converters="using:MyNamespace.ViewModels.ValueConverters"
        mc:Ignorable="d"
        d:DesignHeight="300"
        d:DesignWidth="600" FontFamily="Global User Interface">
        <UserControl.Resources>
            <Converters:MyConverter x:Key="MyConverter"/>
        </UserControl.Resources>
        <d:UserControl.DataContext>
            <ViewModels:MyViewModel />
        </d:UserControl.DataContext>
        ...
    </UserControl>

    Now when I open MyControl in the design view and try to add MyConverter, intellisense only finds MyOtherValueConverter which is defined in the current project and do not find MyConverter which is in a referenced assembly, but as soon as removing MyOtherValueConverter or moving it to another namespace, intellisense finds MyConverter.

    The same situation happens if there are multiple assemblies with the same namespace for ValueConverters. It seems that when VS intellisense discovers some ValueConverters in one assembly it does not search through other assemblies to find other ValueConverters but it compiles and run the code perfectly fine. So it seems to me like a VS intellisense bug to me.

    Friday, April 11, 2014 3:45 PM