Tim Anderson asked a question on the MSDN forum for WPF.
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 assembly
Use <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 assembly
Use <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 world
Don't put it in your .csproj/.vbproj...put it up on some server or in the file system.
In WPF, we only support event wiring/code with A.
A few blog posts that go into more details about this include:
A) 3 Coding Styles for Avalon Applications
B) MarkupCompilation: XAML, BAML, .g.cs Details
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).