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>
But I get this error when I run the loose XAML in IE:
The tag 'List' does not exist in XML namespace 'clr-namespace:System.Collections.Generic;assembly=mscorlib'. Line '7' Position 2'.
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.
xaml. If the style is not found in the theme dictionary, it looks in Generic. xaml i.e for controls whose look doesn't depend on the theme. This only applies to any custom controls you have defined i.e. classes derived from Control, directly or indirectly.
WPF supports techniques that enable specifying the value of some properties of type Type without requiring an x:Type markup extension usage. Instead, you can specify the value as a string that names the type. Examples of this are ControlTemplate. TargetType and Style.
A XAML namespace is really an extension of the concept of an XML namespace. The techniques of specifying a XAML namespace rely on the XML namespace syntax, the convention of using URIs as namespace identifiers, using prefixes to provide a means to reference multiple namespaces from the same markup source, and so on.
I've just tested your sample with Internet Explorer 9. IE9 uses PresentationHost.exe
to render the content and on my system (Windows 7 SP1 x64), and by examining which assemblies are actually loaded I confirmed that it uses the v3.0 framework which does not support XAML 2009.
The documentation describes that for XBAPs it chooses which framework version to load and so it is clearly capable of using the v4.0 framework which does support XAML 2009 for loose XAML. However, the documentation unfortunately does not say which version of the framework it will choose for loose XAML as opposed to XBAPs.
Empirically, at least with your sample, I can confirm that PresentationHost.exe
chooses the v3.0 framework. I cannot find any way to override this selection, for example by annotating the XAML somehow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With