XAML 2009 Features: FactoryMethodArguments

This is part of a series on New WPF\XAML Features

Another new feature in XAML 2009 is the possibility of creating objects using the non-default constructors. The keyword here is x:Arguments

So creating a person object with a constructor requiring Name\Age could be written in XAML as








Next interesting feature is using FactoryMethods… the keyword here is x:FactoryMethod

<p:Guid x:FactoryMethod='NewGuid'/>


You could also combine x:Arguments with FactoryMethod

<coll:List x:Key='list' x:TypeArguments='x:String' x:FactoryMethod='local:Factory.CreateStringList'>






Sample app showing usage is attached

Note that XAML 2009 features work only for loose XAML in WPF.

Share this post