问题与X:TypeArguments和XAML泛型列表类

问题描述:

我创建了下面的标记为一个松散的XAML文件。

I created the following markup for a loose XAML file.

<StackPanel 
  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"
  xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib">
    <scg:List x:TypeArguments="sys:String">
        HelloWorld
    </scg:List>
</StackPanel>

但是当我运行在IE浏览器的松散XAML我得到这个错误:

But I get this error when I run the loose XAML in IE:

标签'名单'中不XML命名空间存在'CLR命名空间:System.Collections.Generic;装配= mscorlib程序。线7位置2。

The tag 'List' does not exist in XML namespace 'clr-namespace:System.Collections.Generic;assembly=mscorlib'. Line '7' Position 2'.

正如你所知道的,在XAML泛型是在2009年XAML功能,可以只在松散XAML文件中的大部分工作。但上面的code不工作。

As you would know, generics in XAML are a feature in XAML 2009 and can work for the most part only in loose XAML files. But the above code doesnt work.

为什么发生这个错误以及如何纠正问题的任何线索?先谢谢了。

Any clue why this error occurred and how to rectify the issue? Thanks in advance.

该问题已得到解决。我需要包括标记,以便能够使用泛型以下命名空间的映射。

The issue has been resolved. I needed to include the following namespace mapping in the markup to enable use of generics.

的xmlns:V4 =htt​​p://schemas.microsoft.com/netfx/2009/xaml/$p$psentation

xmlns:v4="http://schemas.microsoft.com/netfx/2009/xaml/presentation"

现在它工作正常。