Rob Relyea


March 2006 - Posts

  • XAML and IL

    Filed under:

    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).

  • XAML Language and XAML Formats

    Filed under:

    There are several ways that people use the term XAML:

    1) XAML Language - the core language.  This defines how a XamlReader treats elements, attributes and content in an XML file to represent a tree of objects. One mapping is to CLR based objects.

    We haven't yet published the XAML Language spec.  Chuck's XAML posts (in reverse order) provide a good start.

    2) WPF XAML - the set of elements which describe Windows Presentation Foundation based content - Vector Graphics, Controls, 3D, Documents, etc...

    The best reference on WPF XAML is the Windows SDK.

    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.)

    Xml Paper Specification.  OverviewSpec Download.

    4) "WPF/E" XAML - WPF/Everywhere - a subset of WPF XAML which will be release for cross platform use.  For example, current plans call for no 3D and fewer Controls in WPF/E XAML.

    WPF/E XAML has been talked about in some detail in this blog post and at Joe Stegman's presentation at Mix06.

    5) WF XAML - the series of elements which describe Windows Workflow based content - Activities, etc...

    More Info.


    [I plan to keep growing this list and the detail on each of topics.]

  • C++ applications using XAML

    Filed under:

    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...)


  • Short Video showing basic XAML and Databinding

    Filed under:

    David Betz posts a nice video demo of some basic Databinding in XAML.

    Few notes that I took about the demo:

    1) The color capture of the video didn't make the gradient look very good.  Very banded.  Yes, it wasn't going to look much prettier...but at least the gradient will look a bit smoother.

    2) David was using a build previous to the Feb major difference in Feb CTP would be that you wouldn't need the Mapping PI that he used...instead you would just use:


    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.


    For more on WPF databinding, I can recommend:

    Namita Gupta's PDC talk (September 2005)
    Beatriz Costa - a WPF team member blogging on Databinding.


  • XAML used for Windows Workflow

    Filed under:

    The WPF and WF teams have worked together to make sure our markup formats are both XAML.

    See a bit about using XAML for Workflow in this article.  Comments on the article should go on this post from K. Scott Allen.

    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...

  • interview/demo from Mix06

    Filed under:

    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...

    (updated link to interview...was broken...)

  • Watching Mix06 from Redmond

    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. 

    Update: Bill just said it is available today...get it.

    I just upgraded my wife's computer to it last week.  We went away for a ski weekend so she hasn't put much time in on it yet...


    Bill's keynote: (9am PST)


    Dean's keynote: (after Bill)


    Michael Wallent, Fil Fortes and Robert Ingebretsen have WPF focused talks.  More on that when I find links...

    If you are there...would love to hear what you think about the conference, keynotes, sessions.


  • Windows Vista DWM (Desktop Window Manager) Details

    Greg Schechter rejoins us after a lengthy blogging pause to describe profound changes how Windows Applications render to the screen.

    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 catch it soon if you desire.

      PRS435: Going under the Hood to Understand the Architecture

    (link stolen from Fil's list of WPF PDC talks)