Zulfiqar's weblog

Architecture, security & random .Net

XAML Schema Language

Posted by zamd on November 16, 2008

As mentioned in previous post WF v4.0 is enhanced in many ways and one of those is “Complete workflow/activity authoring in XAML”.

A key enhancement to support this feature is the addition of Schema support in XAML. While  XAML is used to represent objects but there was no way to specify type information in XAML. Schema support provides exactly this functionality using XAML vocabulary. Let’s explore this feature. In the  PDC bits XAML Schema functionality is available in System.XAML.Runtime.dll assembly in (System.Runtime.Xaml.Schema) namespace.

Let’s create a simple type in c#.

public class Employee


    public string Email { get; set; }

    public bool SendEmail() { return true; }

    public event EventHandler NewMessage;


Now this same type can be created in XAML using XAML Schema language. But here I will use a slightly different approach and will convert above type to its XAML schema representation using following simple code.

static void Main(string[] args)


1.  var resolver = new XamlSchemaTypeResolver();

2.  SchemaType st =resolver.GenerateSchemaTypes(Assembly.GetExecutingAssembly()).First();

3.  string xaml = XamlServices.Save(st);


What I get back is this:

<p:SchemaType BaseType="p:Object" Name="p1:Employee"




  <p:SchemaProperty Name="Email" Type="p:String" />

  <p:SchemaMethod Name="SendEmail">

    <p:Signature ReturnType="p:Boolean" />


  <p:SchemaEvent Name="NewMessage">


      <p:Signature ReturnType="{x:Null}">

        <p:SignatureParameter Direction="In" Name="sender" Type="p:Object" />

        <p:SignatureParameter Direction="In" Name="e" Type="s:EventArgs" />






The SchemaType object on line 2 has an attached property which link it back to the type from which this object was generated.

This exactly same language is used to declare arguments/data flow when defining workflow/activities in XAML. Schema language provided the solution to construct new types in XAML without falling back to code which was one of major hurdle in  the authoring of  XAML only workflows in V1.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: