how can I load an image into an Image control at runtime - and have it show ? [modified]
-
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
-
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
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/
-
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/
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