A problem with ContentTemplateSelector

3 posts, 1 answers
  1. M
    M avatar
    4 posts
    Member since:
    Mar 2012

    Posted 16 Jul 2012 Link to this post

    Hi there,
    I have bound the ItemsSource property of RadTileView to an ObservableCollection containing items with INotifyPropertyChanged interface implementation, and also I am using a ContentTemplateSelector that determines the template for the content of TileViewItems based on a property of the corresponding item named "Template".
    The first time the RadTileView loads, it calls the template selector and sets the templates correctly, but if I change the "Template" property of any item in items source bound collection, the RadTileView does not call the template selector to determine the appropriate template again. It needs to set the ItemsSource of the RadTileView again to reflect the changes.
    Is ther any solution to avoid setting the ItemsSource property every time I change the "Template" property of bound items?
  2. Answer
    Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 19 Jul 2012 Link to this post


    We've already replied to the forum thread you started for Silverlight. However, I will paste the same reply here as the approach can be used in both frameworks:

    The problem in your case is that the ContentTemplateSelector is called only when the containers are generated (this is the default behavior of all selectors) and that's why it's not triggered on property change. If you want to be able to change the ContentTemplate runtime you'll have to bind the ContentTemplate property of the RadTileViewItem to the Template property in your business object and use a converter.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. M
    M avatar
    4 posts
    Member since:
    Mar 2012

    Posted 21 Jul 2012 Link to this post

    Thanks Tina
    Your answer is really helpful
Back to Top