Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1810
Creating data template using XamlReader.Load() method.
posted

Hello,

I want to create the DataTemplate in runtime using XamReader.Load method, however i am successful in creating but i have couple of queries.

 

DataTemplate :

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

TemplateColumn radioColumn = new TemplateColumn

();

radioColumn.Key = DisplayName;

 

collayout.Columns.Add(radioColumn);

 

 

 

string str = "<DataTemplate "

+

 

 

 

"xmlns=" + "\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"" + " "

+

 

 

 

"xmlns:x=" + "\"http://schemas.microsoft.com/winfx/2006/xaml\"" + ">"

+

 

 

 

"<StackPanel Orientation=" + "\"Horizontal\"" + ">"

+

 

 

 

"<RadioButton " +" GroupName=" + "\"A\"" + " IsChecked=" + "\"{Binding Path=" + SelectionColumnName + "}\""

+

 

 

 

" Checked=" + "\"RadioButton_Checked\""

+

 

 

 

">"

+

 

 

 

"<TextBlock Text=" + "\"{Binding Path=" + DisplayName + "}\"" + "/>"

+

 

 

 

"</RadioButton>"

+

 

 

 

"</StackPanel>"

+

 

 

 

" </DataTemplate>"

;

radioColumn.ItemTemplate = (

 

 

DataTemplate) XamlReader

.Load(str);

i want to apply styles and want to handle the Checked ,UnChecked events too for the RadioButton control , but its giving runtime error.

Could you please help out.

Thanks,

P.Tilwani