Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Silverlight 4, DataGrid Image Column.

Posted on 2011-09-13
2
Medium Priority
?
871 Views
Last Modified: 2013-12-17
I am using TelerikRadGridview, but I think there is not much difference for my desire.

.XAML:
 
<telerik:RadGridView Margin="22,77,25,0" Name="radGridView1" VerticalAlignment="Top" Height="450" telerik:Theming.Theme="Windows7" CanUserReorderColumns="True">


            <telerik:RadGridView.Columns>
                <telerik:GridViewColumn Header="ImageDisplay">
                    <telerik:GridViewColumn.CellTemplate>
                        <DataTemplate x:Name="dtTemp">
                            <Image x:Name="ImageDisplay2"/>
                        </DataTemplate>
                    </telerik:GridViewColumn.CellTemplate>
                </telerik:GridViewColumn>
            </telerik:RadGridView.Columns>

Open in new window


.CS
 
DomainService1 DS1 = new DomainService1();
            radGridView1.ItemsSource = DS1.Descriptions;
            DS1.Load(DS1.GetDescriptionsQuery());

Open in new window


I want to display Image Column in RadGridview, with URL from the SQL Database.
How can I set Source for this code:

<DataTemplate x:Name="dtTemp">
                            <Image x:Name="ImageDisplay2" Source = HowToSetThisFromDatabase/>
                        </DataTemplate>

Open in new window



The data is binded by using DomainService.


Please help me this problem.
0
Comment
Question by:JameMeck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Dennis Aries earned 2000 total points
ID: 36529448
A nice way is to use a converter that takes your URL and returns the image for you.
Check out the article at the DotNetCurry.

Taken from the code in that article (converts stream to image).
public class ImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            MemoryStream memStream = new MemoryStream((byte[])value,false);
            BitmapImage empImage = new BitmapImage();
            empImage.SetSource(memStream);
            return empImage; 
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Open in new window


Code can be easily modified to take an URL, read the data as a stream and convert that to the image you need.
0
 

Author Closing Comment

by:JameMeck
ID: 36558037
Thanks! I got it.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question