TestAPI
CoreMVVM
XamlPadX
Xaml Compliance
In Xaml2009, we have built-in support for common CLR types which simplifies authoring. So rather than specifying something like
<s:String xmlns:s="clr-namespace:System;assembly=mscorlib"> Foo </s:String>
We can use the notation <x:String > Foo </s:String>
The list of types supported is below:
• <x:String>
• <x:Char>
• <x:Single>
• <x:Double>
• <x:Boolean>
• <x:Byte>
• <x:Int16>
• <x:Int32>
• <x:Int64>
• <x:Decimal>
• <x:Object>
• <x:Uri>
• <x:TimeSpan>
• <x:Array>
One thing to note is wrt WPF this will work only in loose Xaml. This means that these features cannot be used within Cider\Blend. Rob has a post clarifying the absence of tooling support.
Now you get the slight change in title J
[This is part of a series on New WPF\XAML Features]
Dude, WTF... I thought the whole reasoning with using Xml for UI was toolability, and, ironically, the tools are by far the worst part of the WPF experience.
Robert, we understand that this is not ideal. Please read the clarifying post\comments by Rob http://blogs.windowsclient.net/rob_relyea/archive/2009/05/20/yes-xaml2009-isn-t-everywhere-yet.aspx
That's a strange feature...
The only reason using <x:string> works like that is because you declare the namespace in a parent tag. Most xaml files by default will start something like this:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
... which is the only reason the unqualified "x:" namespace will work.
If you add the "xmlns:s" declaration to your root element, then your unwieldy example becomes no heavier than the new alternative:
xmlns:s="clr-namespace:System;assembly=mscorlib">
...
<s:String> Foo </s:String>
And the tools support that just fine, don't they?
I'm not sure what this adds/improves beyond the single missing namespace ref - is there something in the new tags that improves parsing/construction of the objects? Or is this really just changing an "s" to an "x"?
Daniel, the xaml generated by tools like cider and Blend always have the follows namespaces declared by default (and not just the first one)
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Sorry Lester, I realise that - I omitted the namespace more for brevity than anything else.
I think my point is still reasonable, though. Is there a significant difference between these two (more complete) examples?
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">">http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<x:String x:Key="foo">Bar</x:String>
</Page.Resources>
</Page>
<s:String x:Key="foo">Bar</s:String>
I was just wondering if there are any other benefits beyond a single missing namespace reference.
as mentioned, it is an improvement in the authoring experience.
What would have been a real improvement would be the ability to include multiple namespaces in the default namespace. Or some project-wide mappings so I don't have to junk up every xaml file with the same mappings.
Thats good feedback John. We'll consider it for future releases.