How to read datatemplate name from gridview column definition

2 posts, 0 answers
  1. Karel
    Karel avatar
    11 posts
    Member since:
    Aug 2011

    Posted 06 Aug 2014 Link to this post


    I am trying to create gridview's columns dynamically and it works ok, I have my own object with all properties I want to set on columns. One of them is CellTemplateName so I can set column.CellTemplate = Resources[columnDefinition.CellTemplateName] as DataTemplate and it works ok.

    The problem is when I want to read and save column definitions from gridview. Then I don't know how to get this CellTemplateName. I tried to get column.CellTemplate.DataTemplateKey but it is null.

    Can you help what is the right way how to get the correct resource name of the cellTemplate?

    Thank you,
    Karel Bem
  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 07 Aug 2014 Link to this post

    Hi Karel,

    I am afraid there is not such a property holding the name/key of the DataTemplate set as column's CellTemplate available.
    As to Binding columns dynamically, you can check this github example on Binding columns from view model which allows dynamically adding and removing columns. 
    Although GitHub is a very well-known platform we saw a better and easier approach for reviewing our examples developing our brand new SDK Samples Browser. You can also use it to review the examples.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top