Databind image source with RIA Services

2 posts, 0 answers
  1. Rick Mueller
    Rick Mueller avatar
    103 posts
    Member since:
    Feb 2010

    Posted 14 Jan 2011 Link to this post

    I have a Coverflow control binded to basic Northwind category table with 8 images.
    I have btyes[] text appear instead of image, I pass the binding thru a converter and the IE crashes on debugging
    Please any thoughts?
    <navigation:Page.Resources>
           <local:ImageConverter x:Key="ImgCon"/>
       </navigation:Page.Resources>
    <telerik:RadCoverFlow DisplayMemberPath="Picture" ItemsSource="{Binding ElementName=categoryDomainDataSource, Path=Data}" >
                                   <telerik:RadCoverFlow.ItemTemplate>
                                       <DataTemplate>
                                   <Border>
                                               <Image Source="{Binding Picture, Converter={StaticResource ImgCon}}"  telerik:RadCoverFlow.EnableLoadNotification="True" />
                                   </Border>
                                       </DataTemplate>
                                   </telerik:RadCoverFlow.ItemTemplate>
                               </telerik:RadCoverFlow>
      my Ria Service Source
    <riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my1:Category, CreateList=true}" Height="0" LoadedData="categoryDomainDataSource_LoadedData" Name="categoryDomainDataSource" QueryName="GetCategoriesQuery" >
                <riaControls:DomainDataSource.DomainContext>
                    <my1:RecipeContext />
                </riaControls:DomainDataSource.DomainContext>
            </riaControls:DomainDataSource>
    Converter
    public class ImageConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                BitmapImage bmi = new BitmapImage();
                if (value != null)
                {
                    byte[] byteBlob = value as byte[];
                    MemoryStream ms = new MemoryStream(byteBlob);
                    bmi.SetSource(ms);
                }
      
                return bmi;
            }
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
      regards,
    Rick
  2. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 19 Jan 2011 Link to this post

    Hi Rick,

    Can you attach all of the visual studio exceptions and try loading the example again. Hope that the error will appear this time with some more meaningful description as we are not able to determine the problem with the code you have send us.

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