March 2006 - Posts

I'm not 100% clear about the relationship between XAML and IL. As far as I can tell, you can compile XAML but it ends up as BAML rather than IL. Equally, my understanding is that anything you can do in XAML you can also do in C# (declarative vs procedural).

If so, presumably it would be possible to compile XAML to IL, even if this is not what happens. Another interesting question: if C# compiles to IL, but XAML does not, then what are the pros and cons - eg. performance?

In WPF, XAML can be used a few ways.

A) Compiled into the assemblyUse <Page Include="Page1.xaml" /> in a .csproj/.vbproj file to get it compiled into the assembly. (It will be stored as a .baml file...and it will have a corresponding .g.cs/.g.vb file).

B) Included in the assemblyUse <Resource Include="Page1.xaml" /> in a .csproj/.vbproj file to get it included in the assembly, but left as a XAML text file.

C) Distributed with the app, but not in the assembly.Use <Content Include="Page.xaml" /> in a .csproj/.vbproj file to make sure click-once knows about the file (it is listed in the .exe.manifest) and will be distributed with the exe.

D) Loose in the worldDon't put it in your .csproj/.vbproj...put it up on some server or in the file system.

Yes, XAML could be compiled into all code instead of half BAML and .g.cs (in fact we used to do it that way).

XPS has chosen to distribute XAML in text form in an XPS file. XPS doesn't support having IL in the XPS file.Most WPF applications will use compiled XAML.WPF/E will likely use an approach similar to XPS (storing XAML in text form), but will have to solve the addition of IL.

XPS chose to keep XAML as an XML file because it was easier for different devices/printers to consume or create.WPF chose to compile XAML for the perf benefit.WPF/E plans to keep XAML as an XML file. They will get smaller download sizes than WPF since they will be in a .zip file. Parsing performance can be faster if you do work ahead of time (like we do with BAML).

3) XPS XAML - a subset of WPF XAML which has been published as part of independent specification, the open XML Paper Specification (XPS), which describes the architecture of the XPS Document file format—a paginated representation of electronic paper that is based on XML.

Note that the XPS spec uses a subset of WPF XAML elements and also constrains the use of some of the XAML Language features (for example, XPS specifies some property values must be set via attribute syntax or property element syntax...while normally XAML allows either to be used.)

Nish is starting to use WPF with C++.He posts about using C++ and XamlReader.Load together.

There are 3 main ways that an application can use XAML. Nish referred to one of them (code + compiled markup) and shows off another (code + markup using XamlReader at runtime).See 3 Coding Styles of an Avalon Application (note, some syntax may have changed...)

3) David hacks on his object to make it available declaratively. He adds a property. (note, he could have used attribute syntax for that property...instead of Property Element syntax like he does). In order to make an object be expressable in XAML, do the following:

a) make it have a default constructor. b) make its state settable via properties only.

Only one (very minor) problem I saw in the article...Grid.Row and Grid.Column start at 0, not 1. WPF should have thrown an exception, I would think in that case...not sure why we don't. I'll check why we aren't throwing now...

What other declarative formats would work well being described in XAML? Would love to hear your thoughts/feelings on that...

Just watched a short interview with IBloks showing off their new WPF application. I like Dancing man. I'm going to sign up for the beta...looking at their site it looks like they will sell backgrounds for $.99 and a game for $9.99 and media. Interesting...

This morning I'm looking forward to watching the Mix06 online.I'm keeping my head down on work I have on my plate for a while, so I'm not attending. :-(

I'll be following as much of the content as I can at VirtualMix. I'm back to subscribing to blog feeds using IE7's interface...just subscribed to the RSS feed. Rumor has it that a new build of IE7 may be coming out with Mix. Haven't checked internally to see if that is true...but I'll be upgrading if it is.

Greg has contributed a lot to the architecture of WPF. You may have seen Greg, Chris Anderson, and Jeff Bogdan's talk at the October 2005 PDC. I don't think the session will be available online past April...so catch it soon if you desire.