.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Can't update image.source at runtime ( ??? )

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :WPF
I change wpf image.source dynamically during runtime.
Its seen everything is find - the image is not empty ( i saving it to my disk )...
but on the "image.source = ... " i dont see any image on the Image controler.
Actually - i dont see any image on the image controler.

I check if the Image controler can have some hard code image ( not change on runtime ) and its look fine also. Just update the image.source is not update the right image on the runtime.

The code is simple 3 line ... function name that get argument of BitmapImage and then call => image.source = BitmapImage - that it ===> image is the x:Name of the Image object on the xaml.

Any suggestion? what to check ... ? what is wrong ?


View Complete Post

More Related Resource Links

How to change wpf image source on runtime ?


I get new bitmap from some other component ( dont have any control on the other component ) every 5 seconds and i need to update my wpf image control with the new bitmap ( every 5 seconds ... ).


[ i cant save the bitmap to the disk and then load it as file ]

I cant find any way to update this wpf image control in run-time.

How can i do it ?


Image with data source bind won't update on WPF Window


This is the WPF Window Class:

  public partial class MainWindow : Window
    public Bitmap image;
    public CaptureModel cm = CaptureModel.Instance;
    public MainWindow()
      image = cm.Image;
      DataContext = this.image;
      CaptureModel.Instance.PropertyChanged += new PropertyChangedEventHandler(Instance_PropertyChanged);


    void Instance_PropertyChanged(object sender, PropertyChangedEventArgs e)

      if (e.PropertyName == "ImageChanged")
        this.image = cm.Image;


And this is the .xaml for it:

<Window x:Class="TestApplication.MainWindow"

Help ~~ How to Update Binary Image on Formview

Hi All ~~ I'm confused, Can i have some help please... Thanks
Database: Books
uid dataType uniqueidentifier
Cover dataType image 
aspx :
 <asp:FormView ID="FormView1" runat="server" BackColor="LightGoldenrodYellow"   BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="uid"     DataSourceID="SqlDataSource1" ForeColor="Black" Width="525px">
         <table class="table_width">
                 <td class="imageWidth">
                     <asp:Image ID="Image1" runat="server" Height="245px" 
                                       ImageUrl='<%# IIF(Eval("Cover") Is DbNull.Value, "~/Styles/Global/CFZ-No-Images.png", Eval("uid", "~/ImageServices.ashx?BooksID={0}")) %>' Width="180px" />

Use update progress control to change image control imageurl

UPDATE: Apologies for the previous formatting error - hopefully the post is now more readable... Hi I have a button with an image control next to it. Before the button is clicked, the image control "ConfirmedStatusImage" shows a "cancel.png" image. When the button has been clicked (and some other code successfully executed), then I change the imageurl for the "theConfirmedStatusImage" to show a "ok.png" image. Quite a bit of time can often pass between clicking the button and the associated code executing, so I have an ajax update progress control that shows a "bluespinner.gif" image while the page is updating after the button click. At the moment, the update progress updating image appears next to the "ConfirmedStatusImage" control. However, I would like to change things so that when the update progress starts, the imageurl of "ConfirmedStatusImage" changes from "cancel.png" to the update progress image (i.e., the "bluespinner.gif"). Then, when the update is complete, then the image should change to the "ok.png" image. My question is: how can I achieve this? As far as I can tell, the update progress control does not have any events that I can hook into. Also, placing the "ConfirmedStatusImage" inside the ProgressTemplate would not work either, as this only displays

Failed to set image source with string resource

User can set image source property like this: <Image Source="pack://application:,,,/MyResource;component/Images/1.ico" /> I think the source string is a little bit longer, so I want to make it as string resource: <sys:String x:Key="StringSourceKey">pack://application:,,,/MyResource;component/Images/1.ico</sys:String> After define the string resource, I use it to set image source, like this: <Image Source="{StaticResource StringSourceKey}" /> But, this time, it failed. It doesn't work. I think it is a contert error. Anybody know what's wrong?  Or any method to make the resource uri path shorter? Thanks.

How convert bitmap to Image.source ?

I hold some bitmap object in the memory  ( simple System.Drawing.Bitmap ). I want to make some wpf image control to show this bitmap. I dont want to save the bitmap to the disk and then load it as URI to the wpf image control So, How can i do this simple action ?   Thanks.

Using AJAX update panel to show image but still blinking

May anyone help me on this issue please?I'm developing a web site that can grab image captured from cameras and show in the web page, i'm currently using Ajax's Update panel to update the image every second, my web files and Images is located in IIS virtual directory, browsing using IE7.My code is as following :<asp:UpdatePanel ID="uPVideoPane1" runat="server">                                 <triggers>                                     <asp:AsyncPostBackTrigger ControlID="Timer" EventName="Tick" />                                 </triggers>                                 <contenttemplate>                                     <asp:LinkButton ID="linkCamera1" runat="server">                                         <asp:Image ID

linq to sql varbinary assign to image source

Hi All, can you please tell me why this doesnt work:   <Grid> <Image Source="{Binding Path=currentUser.userStatus.icon.bm}" Width="89" Height="90" Margin="309,140,270,99" Name="im" /> </Grid>   where as if I assign the image source via the code behind it does? im.Source = currentUser.userStatus.icon.bm; The currentUser.userStatus.icon.bm object is a BitmapImage type generated from a database varbinary field using linq to sql partial methods like this:   public partial class icon { public BitmapImage bm = new BitmapImage(); public System.Drawing.Icon ic; public System.Drawing.Image img; partial void OnLoaded() { byte[] data = (byte[])this.imageBinary.ToArray(); MemoryStream strm = new MemoryStream(); strm.Write(data, 0, data.Length); strm.Position = 0; img = System.Drawing.Image.FromStream(strm); System.Drawing.Bitmap b = (System.Drawing.Bitmap)img; ic = System.Drawing.Icon.FromHandle(b.GetHicon()); //string imagePath = "Icons/go-down-8.ico"; //System.Drawing.Image img = System.Drawing.Image.FromFile(imagePath); //BitmapImage bi = new BitmapImage(); bm.BeginInit(); bm.DecodePixelWidth = 128; MemoryStream ms = new MemoryStream(); if (this.ext

One needs to press F5 for image to update...



I have a forum where one can change his profile picture. I am using file upload. The problem is that when someone upload another picture for his profile image, the previous image is still present. But when pressing F5 the page refreshes and the new image is shown. 

Also I have some users that when they sign out, close the browser, and they come another day, their profile image is still shown (but they aren't logged in). When they press F5 all the logged in contents disappears.

I think that the browser is saving some sort of something.

Is there anyway to eliminate this problem? 

Thanks in advance,

Roderick Vella

Value Converter Without Binding On Image Source


I need to get the path of an image through a value converter. However I can't find any examples of using a value converter without binding.

I would be looking to do something along these lines:

<Image source="{Value=Image1, Converter={ImageConverter}}" />

The image converter will then go check an image folder and return the correct file path.

How to update iFrame source from twolistboxes on selected item value???


I have a two listboxes where I generate content from XML. I define UriSource in XML. I'd like to find out how I can update Frame's Source property from two different lisboxes. Any ideas are highly appreciated.


Listboxes and Frame:

<Grid x:Name="PANEL_BottomArea_Grid" DataContext="{Binding Source={StaticResource PagesData}}">


 				<ColumnDefinition Width="215"/>


Set Image Source to DIB in Memory?


Hello all.

I have a piece of hardware saving image data to memory which I would like to retrieve and set as the source to an Image element.  I am able to ask the hardware for a DIB handle to the image -- the return value is documented as "a long, which should be cast to a HBITMAP".  How can I do this in WPF?

I'm currently reading up on BitmapSource.Create(), which takes an IntPtr to memory, but I'm not sure it is expecting a DIB or not.  Also, the function asks for "stride" which I am unfamiliar with computing.  This appears to be the most promising though, since I can set it straight to an Image.Source parameter.

The hardware I have also has a function to grab a LPPICTUREDISP handle, which is documented as being compatible with the "Picture Object" of Visual Basic and C++.  From my reading so far it doesn't sound like this is something that is better suited for my needs, but I'm not sure.

Thanks for any help

aggregate data source update data



I've been building .aspx pages in sharepoint designer using the aggregatedatasource to perform calculations referencing data from different lists and displaying the calculation results to the user.

I'd like to build a form that combines user alterable fields in one list, and display calculation results based upon the primary list and several other reference lists.

Does anyone have a post or link to an article showing how to do this?

i.e. I have fields that the user can input data into, click [Save], the form refreshes displaying the new calculation results which read data from many different lists.

Best regards,


Force update of bound combobox when validation changes bound source property


.NET 3.5SP1, VS 2008

I have inherited a system for maintenance and I'm working my way through defect reports.  Once such issue involves insuring a combobox value is reset to a known good value when a validation failure occurs.  The combobox is bound to a source property loaded which is initialized when the user selects a case for update.  According to this post it is an issue inside of WPF to ignore value changes when processing an update to the source (at least that's how I interpret the post).  Unfortunately for me, the UpdateSourceTrigger for a combobox is PropertyChanged, so the suggested approach does not fit my needs.  I tried it anyway, just to be certain.

I've created a test app which mimics the application design and exhibits the behavior I'm attempting to work around.  At this point, I'm at a loss how to proceed further.  I'm certain there's something I'm missing and would appreciate a nudge in the proper direction.

xaml window:

<Window x:Class="TestWpf.ComboTest

Scaling an image source

I have an image in which I set the image.Source to a writeableBitmap - I want to know how to scale the image.Source so the whole writeableBitmap fits into the image control initially, to avoid having to scroll.

SSIS : Insert, Update, Delete records from destination table by comparing records in source table.


Requirement: Inse

rt, Update, Delete records from destination table by comparing records in source table.

Update: if records exist in both the table compare them, and update value in destination table if value is different.

Insert: if record doesn't exist in destination table, add new record in destination table.

Delete: if record exist in destination table but not in source table, delete record from destination table.

----> I have created an SSIS package that does all this task but in order to perform delete operation, I have to store all records of destination table into a temporary table.
And since it's not the most efficient way, I have created another SSIS package by using Lookup & conditional Splits
method, now it works fine with inserting and updating information but I am not sure on how to handle removing record operation!

I would really appreciate if you could help me with this.

(In order to archive inserting and deleting records, I have referred following thread!
http://sqlblog.com/blogs/andy_leonard/archive/2007/07/09/ssis-design-pattern-incremental-loads.aspx )

Data View Web Part, update to Data Source / adding new list to existing data source


Hi all,

I have four Lists with identical columns :

List 1
List 2
List 3
List 4

I had to merge them, hence i created a data source ( Linked Source ) and merged these lists in SPD. I have used a data view webpart to display some columns from the merged lists data source and everything was working fine.

But now i have a new List : List 5 which also has the same columns like the other four lists and i need to update the data soure such that it is merged list of 5 lists not 4.

i updated the datasource property of the linked source to merge this new list as well. However the contents of List 5 dont appear in the data view webpart. 

Am i missing something here ? 

I dont want recreate the data view web part from scratch eachtime , because in future there might be List 6 , List 7 as well ... 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend