Bind Images to RadDataBoundListBox

Thread is closed for posting
2 posts, 1 answers
  1. Robert
    Robert  avatar
    68 posts
    Member since:
    Feb 2009

    Posted 12 Apr 2011 Link to this post


    It's my understanding that the RadDataBoundListBox for Windows Phone 7 does not support direct content.

    My goal is to load 12 images from a folder named Images, and I am trying to bind an image (defined in the application folder named Images) to the RadDataBoundListBox.

    During testing, 12 lines of System.Windows.Media.Imaging is displayed on the Windows Phone 7 - rather than 12 instances of the hard-coded image.

    Any insight is appreciated, and the below code is being utilized in this test case.




    bi3 = new BitmapImage();



    bi3.UriSource = 


    new Uri("Images/GreenPea.png", UriKind.Relative); 






    <BitmapImage> months = new ObservableCollection<BitmapImage>();







    foreach (string monthName in DateTimeFormatInfo.CurrentInfo.MonthNames)










    this.radDataBoundListBox.ItemsSource = months;



  2. Answer
    Deyan avatar
    2147 posts

    Posted 13 Apr 2011 Link to this post

    Hello Robert ,

    Thanks for contacting us.

    In order for your approach to work as expected, you will have to additionally define a special DataTemplate for your items which will contain an Image which you will use to display the BitmapImage instances in your collection. This is the default way of representing any type of special content in Silverlight. Take a look at the following XAML code snippet:

                      <Image Source="{Binding <Path_to_the_Image_Source>}"/>

    As you can see, I have defined a DataTemplate which contains an instance of the Image class. The Image class is the visual representation of an image in the visual tree. You can also see that I am using the Source property of the Image class and bind it to the path to the image in the business object (the object that comes from the collection I have used to fill my listbox). If you want to bind directly to the business object instead of a property, simply use Source={Binding}.

    I hope this helps.

    Do not hesitate to get back to us in case you have further questions or need assistance.

    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top