Changing RadCustomHubTile Datatemplate Image Programmatically

Thread is closed for posting
2 posts, 0 answers
  1. Laurensius
    Laurensius avatar
    17 posts
    Member since:
    Jan 2014

    Posted 06 Mar 2014 Link to this post

    Hi i have this xaml in my app
    <telerikPrimitives:RadCustomHubTile x:Name="food"                                              
                        <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
                    <Image x:Name="foodImage" Source="/Assets/Icons/food.png" />
    and i want to change image source of foodImage, but it won't allow me to do that in c#.. any idea why?

  2. Victor
    Victor avatar
    1358 posts

    Posted 11 Mar 2014 Link to this post

    Hello Lauresnius,

    Thanks for the question.
    The trick is to use data binding. You need to bind the Source property of your Image to a property of the data context of the data template. The data context will be the object you set as the FrontContent of the hub tile.

    For example if you have a class MyViewModel with a property of type ImageSource with the same name, you can set the FrontContent to an instance of MyViewModel. Then your Image will bind like this <Image ImageSource="{Binding ImageSource}"/>. When this is done, all you have to do is to set a new ImageSource to your view model and the view will update itself. For more info please have a look at the MVVM design pattern.

    Please write again if you have other questions.


    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Back to Top