问题与X:TypeArguments和XAML泛型列表类 [英] Issue with x:TypeArguments and generic List class in XAML

查看:801
本文介绍了问题与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"

现在它工作正常。

这篇关于问题与X:TypeArguments和XAML泛型列表类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆