Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9099757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:42:02+00:00 2026-06-17T00:42:02+00:00

I am having trouble getting an image to disply in a DataGrid (WPF)… Any

  • 0

I am having trouble getting an image to disply in a DataGrid (WPF)… Any ideas?

Soooooo easy in WinForms DataGridView – sigh

Datatable

Dim DGV As CustomControl.DGVx = ImagesItemsGrid.FindName("ImagesItems_DGV")
            Dim DS As DataSet = e.Result
            Dim DT As DataTable = DS.Tables(0).Copy
            Dim vDT As New DataTable
            With vDT.Columns
                .Add("ID", GetType(Integer))
                .Add("Name", GetType(String))
                .Add("Description", GetType(String))
                .Add("Image", GetType(Image))
            End With

Image

Dim vImageHeight As Integer = 0
            For Each Row As DataRow In DT.Rows
                With vDT.Rows
                    Dim ImageData As Byte() = DirectCast(Row("Image_Icon"), Byte())
                    Dim vImage As New Image
                    Dim vBitMap As New BitmapImage
                    Using vStream As New IO.MemoryStream(ImageData)
                                                    vImage.Source = BitmapFrame.Create(vStream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad)
                    End Using
                    vImage.Height = 20
                    .Add(Row("Image_ID"), Row("Image_Name"), Row("Image_Description"), vImage)

                End With
            Next
            DT.Dispose()

Columns

For Each Col As DataColumn In vDT.Columns
                Dim vDataType As String = Col.DataType.ToString
                Select Case vDataType
                    Case "System.Int32"
                        DGV.Columns.Add(New DataGridTextColumn With {.Header = Col.ColumnName, .Binding = New Binding(String.Format("[{0}]", Col.ColumnName))})
                     Case "System.Windows.Controls.Image"

                        Dim ImageCol As New DataGridTemplateColumn
                        ImageCol.Header = Col.ColumnName
                        Dim vFactory As New FrameworkElementFactory(GetType(Image))

                        Dim vBinding As New Binding(String.Format("[{0}]", Col.ColumnName))
                        vBinding.Mode = BindingMode.OneWay
                        vFactory.SetValue(Image.SourceProperty, vBinding)

                        Dim vCellTemplate As New DataTemplate
                        vCellTemplate.VisualTree = vFactory
                        ImageCol.CellTemplate = vCellTemplate
                        DGV.Columns.Add(ImageCol)



                    Case Else

                        Dim DGTC As New DataGridTextColumn
                        With DGTC
                            .Header = Col.ColumnName
                            .Binding = New Binding(String.Format("[{0}]", Col.ColumnName))
                        End With
                        DGV.Columns.Add(DGTC)
                End Select



            Next

Data

DS.Dispose()
            DGV.DataContext = vDT
            DGV.ItemsSource = vDT.DefaultView

The the text data is showing as it should but, although the column is there, nothing for the images…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:42:04+00:00Added an answer on June 17, 2026 at 12:42 am

    Turns out the answer is just to leave the ‘image’ as Byte()

    It now works

    Case "System.Byte[]"
    
                            Dim ImageTemp As New DataTemplate
                            Dim ImageCol As New DataGridTemplateColumn
                            Dim vFactory As New FrameworkElementFactory(GetType(Image))
                            Dim vBinding As New Binding(Col.ColumnName)
                            vFactory.SetBinding(Image.SourceProperty, vBinding)
                            ImageTemp.VisualTree = vFactory
                            ImageCol.CellTemplate = ImageTemp
                            DGV.Columns.Add(ImageCol)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting a background-image to overlay the border of another div.
Having trouble getting fancybox to display my image correctly, I use ASP.NET: <a class=fancybox
I have been having trouble getting my banner image on my blog to be
I am having trouble getting my background image to span the entirety of my
Having a little trouble in getting image attachment urls in wordpress. This is my
I am having trouble getting my Form background image to display correctly with a
I'm having trouble getting an image to scale and center properly in an ImageView.
I'm having trouble getting the image width and height when generating a sprite from
I'm having abit of trouble getting an image from a website and showing it
im having trouble getting a string (containing a URL) from one activity to another.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.