WindowlessControls Tutorial - Part 3

Cross compiling Mono is making me quite the productive blogger! This tutorial will expand on the ImageButtons I used in the previous tutorial. The buttons we placed only had a single image: nothing happens when they are focused or clicked. However, the class does support animated buttons! Using the previous tutorial code as a base to set up our background, I will add the new animated buttons:

// focus state bitmap
PlatformBitmap focused = PlatformBitmap.FromResource("Btn1.png");
// normal unselected state bitmap
PlatformBitmap unfocused = PlatformBitmap.FromResource("Btn1_Disabled.png");
// clicked state bitmap
PlatformBitmap clicked = PlatformBitmap.FromResource("Btn1_Pushed.png");

// set up the image button by setting the properties manually
ImageButton button1 = new ImageButton(unfocused, Stretch.None);
button1.Control.FocusedBitmap = focused;
button1.Control.ClickedBitmap = clicked;
button1.BackColor = Color.Transparent;

// OR set the button up by setting everything in the constructor
ImageButton button2 = new ImageButton(unfocused, Stretch.None, focused, clicked);
button2.BackColor = Color.Transparent;

// add the buttons

All you need to do is specify the images for the various button states, and the button will handle the animations for you! Click here for the updated tutorial source code.


Anonymous said...

I just found your website and i have to say that your codes are pretty neat i am still in college and trying to learn different and unique ways and i have to say that all your post are unique and that you also give an very good explanation on how the code works. Looks like i will be following all your posts now on this blog. Thanks very much and keep on the good work.

Unknown said...

as a french computer ingeneer who had a WM6 phone for christmas i'm thinking about how to play with this new world. I'm currently working with WPF technology and i'm very pleased with your job as it can make me play with C# and WM6 easier.
Really thanks for your blog ..( and sources too).

Maybe one day, you'll add INotifyPropertyCHanged and binding or even XAML.
Sincerly thanks.