Creating a Silverlight DataTemplate in code -


how create silverlight data template in code? i've seen plenty of examples wpf, nothing silverlight.

edit: here's code i'm using for, based on answer santiago below.

public datatemplate create(type type) {   return (datatemplate)xamlreader.load(           @"<datatemplate             xmlns=""http://schemas.microsoft.com/client/2007"">             <" + type.name + @" text=""{binding " + showcolumn + @"}""/>             </datatemplate>"    ); } 

this works nicely , allows me change binding on fly.

although cannot programatically create it, can load xaml string in code this:

    public static datatemplate create(type type)     {         return (datatemplate) xamlreader.load(             @"<datatemplate                 xmlns=""http://schemas.microsoft.com/client/2007"">                 <" + type.name + @"/>               </datatemplate>"           );     } 

the snippet above creates data template containing single control, may user control contents need.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -