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

 

 

 

 

 

Parents
No Data
Reply
  • 30945
    Offline posted

    Hello Tilwani,

     

    I have been looking into your description and it seems that XamlReader.Load method does not support handling events in the XAML content string. You can read about the this method here: http://msdn.microsoft.com/en-us/library/cc189076(v=vs.95).aspx . I have created a sample application in which using the CellControAttached event of the XamGrid I have handled the Check and Unchecked events of the RadioButtons that are in the template for the column. You can also apply and styles for the elements in the DataTemplate in the event handler of the CellControlAttached.

     

    If you need any further assistance please do not hesitate to ask.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    Sample.zip
Children