views:

161

answers:

1

This is actually two questions in one:

First, when you write your XAML and Intellisense fails to recognize the type you want to use (in my case, Array), what steps do you go through to figure out what's going on? I initially look over my XML namespaces to make sure that everything looks like it's in order. If it's a CLR type (not one of my own), then I end up checking Google (and usually can't find what I need).

In this case, my query was "XAML WPF namespace missing Array", which tells me, as I had suspected, that Array is in http://schemas.microsoft.com/winfx/2006/xaml, but it doesn't show up in Intellisense. Why is that?

All of the examples I see are in a Window or Application, not in a UserControl like mine. Is that related to my problem?

Ok, I guess that was technically three questions. :)

+2  A: 

I'm not sure I really understood what your question is about... If you want to declare an array in XAML, use the x:Array markup extension. Example with an array of Int32 :

<UserControl x:Class="YourNamespace.YourClass"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <UserControl.Resources>
        <x:Array x:Key="arrayOfInt32" Type="sys:Int32">
            <sys:Int32>4</sys:Int32>
            <sys:Int32>8</sys:Int32>
            <sys:Int32>15</sys:Int32>
            <sys:Int32>16</sys:Int32>
            <sys:Int32>23</sys:Int32>
            <sys:Int32>42</sys:Int32>
        </x:Array>
    </UserControl.Resources>

    ...
Thomas Levesque
I just re-read my question, and I realized that I forgot to paste in a code example. However, yours is a good example. My issue is that when I type x:Arr, "Array" doesn't show up in the Intellisense popup. I just get "ArrayExtension".That said, I just decided to use x:Array anyway, and everything still compiled. So is this an Intellisense issue? I am used to it not working well in VC++, but in C# development, Intellisense has never failed me.
Dave
I have the same issue in VS2008 and VS2010. But actually it's not really an issue : it should work even if you write x:ArrayExtension. For markup extensions, the "Extension" suffix can be omitted
Thomas Levesque