Solved

Silverlight 4, DataGrid Image Column.

Posted on 2011-09-13
2
868 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 500 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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

695 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