Wpf updating ui asynchronously

If an image load fails, it inserts an error image and message. This method is really handy and I found it in one of the source links.

For each image URL, a background worker is created to download the image using Web Client on a different thread. This will load up the error image we have in the solution.

I want, that when the user calls the command, it should immediately update the UI disabling the button so the user cannot execute it while it's running, then execute that operation, then, when operation completed, unblock the button.

Recently, I needed to be able to load images from URLs into a WPF window without locking up the UI thread. I add a label then the image to the Stack Panel's Children property.

Along with Data Binding, the support for Model-View-View-Model (MVVM) in WPF has supported code-less development.

In almost all the types of Business applications, a common and an important requirement is where the UI makes a call to an external service for reading data (in most cases a large amount of data).

First I am going to implement a solution with the parallel task library.

Abstract: The Data Binding features provided in WPF 4.5 are very useful for creating Rich Line-Of-Business applications where time and again, the UI needs to be either updated with a collection of data received from external repositories or to perform complex validation checks based upon some complex time consuming logic.

Windows Presentation Foundation (WPF) is Microsoft’s premier technology for creating a broad range of Windows Desktop Apps.

In my scenario the Button_Click is a command delegate in the VM, and the Thread.

Sleep is some long-running process (about 2-10 seconds).

Leave a Reply