Mam*_*a D 8 c# generics xaml .net-4.0 wpf-4.0
我为松散的XAML文件创建了以下标记.
<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>
Run Code Online (Sandbox Code Playgroud)
但是当我在IE中运行松散的XAML时,我收到此错误:
XML命名空间'clr-namespace:System.Collections.Generic; assembly = mscorlib'中不存在标记'List'.线'7'位置2'.
正如您所知,XAML中的泛型是XAML 2009中的一个功能,并且只能在松散的XAML文件中工作.但上面的代码不起作用.
任何线索为什么会发生此错误以及如何纠正问题?提前致谢.
问题已经解决。我需要在标记中包含以下命名空间映射以启用泛型。
xmlns:v4="http://schemas.microsoft.com/netfx/2009/xaml/presentation"
现在效果很好。