Main Site Documentation

Updating A Non Button Bitmap On My Display


First off I’m coding my display following the WPF methods described in most of the books.

It’s working really well for me so far - I have text being updated, and Images on screen, some of which are buttons which change their Resource bitmap when clicked.

This is all just fine. But now I want to update an image (the blue display) based on and controlled by my code and not by a user hitting a button. It seems this isn’t easy to do and I can’t for the life of me work out why.

Does anyone have any experience using this technique that might be able to shed light on my issue (I’ll happily provide further details and code if there is anyone who can help).

Thanks guys!



You are coding in C# right? This board is for posts on native programming, C/C++ in RLP.


Show us how you create that element. Please use ChipworkX board.


Sorry, wrong forum. Can this thread be moved?




You will need to use the dispatcher for updating images on the screen.
See it as a thread safe method in normal .net.

Icon switching using dispatcher class:

void SetControlIcon(Image control, Bitmap icon)
            control.Dispatcher.Invoke(new TimeSpan(0, 0, 1), new DispatcherOperationCallback(UpdateImageControl), new ImageToUpdate(control, icon));

Image update class:

public class ImageToUpdate
        public ImageToUpdate(Image ctl, Bitmap img)
            Control = ctl;
            Image = img;

        public Image Control { get; set; }
        public Bitmap Image { get; set; }

Which can then be used like this:

SetControlIcon(joystickButton, Resources.GetBitmap(Resources.BitmapResources.icon_Joystick));

It’s a little early and I am not fully awake yet, so there might be some error somewhere :smiley:


Wow, that’s awesome, thanks!

All I’d been doing was having various pre-called static Bitmaps

static Bitmap bmpIconPlus = Resources.GetBitmap(Resources.BitmapResources.icon_30x30_plus);
static Bitmap bmpIconMinus = Resources.GetBitmap(Resources.BitmapResources.icon_30x30_minus);

Setting one to an Image along with a .TouchDown event:

Image imageButtonPlusMinus = new Image(bmpIconPlus);
imageButtonPlusMinus.TouchDown += new Microsoft.SPOT.Input.TouchEventHandler(imageButtonPlusMinus_TouchDown);

Then in my Display class function I called ‘UpdateDisplay’ (or within the touchdown method) I re-assigned the bitmap to the image based on some boolean or trigger:

if (booleanSomeTest == true) {
    imageButtonPlusMinus.Bitmap = bmpIconPlus;
} else {
    imageButtonPlusMinus.Bitmap = bmpIconMinus;

I like the way you invoke a/the dispatcher. Does this mean that you can call this event at any point in the code (rather than only being called internally by the Display class as I’m doing)?