Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. how can I load an image into an Image control at runtime - and have it show ? [modified]

how can I load an image into an Image control at runtime - and have it show ? [modified]

Scheduled Pinned Locked Moved WCF and WF
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abiemann
    wrote on last edited by
    #1

    I have a System.Windows.Controls.Image on my window, designed at runtime. No Source is specified. What I'd like to do is specify what image to load whilst the program is running. I've tried: ImageLogo.Source = New Imaging.BitmapImage(New Uri(strLogoFilepath, UriKind.Absolute)) (strLogoFilepath contains the absolute location of the .jpg) but nothing is shown! After this statement the actualheight of the control is still 0.0 :confused: :( How can I get the image control to show the jpg at runtime ?

    modified on Thursday, September 3, 2009 9:48 PM

    A 1 Reply Last reply
    0
    • A abiemann

      I have a System.Windows.Controls.Image on my window, designed at runtime. No Source is specified. What I'd like to do is specify what image to load whilst the program is running. I've tried: ImageLogo.Source = New Imaging.BitmapImage(New Uri(strLogoFilepath, UriKind.Absolute)) (strLogoFilepath contains the absolute location of the .jpg) but nothing is shown! After this statement the actualheight of the control is still 0.0 :confused: :( How can I get the image control to show the jpg at runtime ?

      modified on Thursday, September 3, 2009 9:48 PM

      A Offline
      A Offline
      Arun Jacob
      wrote on last edited by
      #2

      abiemann wrote:

      ImageLogo.Source = New Imaging.BitmapImage(New Uri(strLogoFilepath, UriKind.Absolute))

      This is right.It seems some problems with the path or may be of your XAML.

      Arun Jacob http://codepronet.blogspot.com/

      A 1 Reply Last reply
      0
      • A Arun Jacob

        abiemann wrote:

        ImageLogo.Source = New Imaging.BitmapImage(New Uri(strLogoFilepath, UriKind.Absolute))

        This is right.It seems some problems with the path or may be of your XAML.

        Arun Jacob http://codepronet.blogspot.com/

        A Offline
        A Offline
        abiemann
        wrote on last edited by
        #3

        Actualheight is not updated at all (it stays fixed to whatever value it is set to at design time), so I did this: 'load images according to configuration Dim BitmapImageHeader As New Imaging.BitmapImage BitmapImageHeader.BeginInit() BitmapImageHeader.UriSource = New Uri(strLogoFilepath, UriKind.Absolute) BitmapImageHeader.EndInit() ImageLogo.Source = BitmapImageHeader ImageLogo.Height = ImageLogo.Source.Height I then recalculated the margins for the rest of the controls and I was done. I thought I had read that actualheight is always correct... maybe I remembered it wrong ? heh

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups