This article describes how to develop a mobile application with .NET CF having features like background transparency. There is one set of controls created by Rémy Baudet available at AlphaMobileControls. These controls offer background transparent images, image buttons and labels. I have added the following items to the library provided by
- Modified the
AlphaImage control so that image can stretch itself as per size of the control
In Part I, I shall describe details about the existing
AlphaMobileControls and then in the next part, we will discuss about building controls on top of
Background transparency of the controls
Mobile thick client applications are getting more and more popular every day. When I started developing a client application, I did not have much knowledge about .NET Compact Framework. I found that CF class library controls are not sufficient for creating smart looking UIs. Then I tried a number of third party controls - most of them were either too heavy to use in handheld devices or they are very error prone (specifically memory leakage was the common problem of these third party controls). Then I came to know about
AlphaMobileControls developed by Rémy Baudet. But, they did not have all the features that I wanted, i.e. a key navigable button control and a list control to display list of items.
How Alpha Mobile controls Work !!
AlphaControl has been derived from
control base class and Alpha button derives from alpha control.
public class AlphaControl : Control
public class AlphaButton : AlphaControl
Alpha controls should be placed over an alpha container class - either
alphapanel. This container classes contain the main trick of transparency. It has a
paint method which in turn fires the
draw method of all containing alpha controls:
public void OnPaint(PaintEventArgs e)
if (_backBuffer != null)
using (Graphics gxBuffer = Graphics.FromImage(_backBuffer))
Region gxClipBounds = new Region(Rectangle.Ceiling(gxBuffer.ClipBounds));
for (int i = _control.Controls.Count - 1; i >= 0; i--)
AlphaControl ctrl = _control.Controls[i] as AlphaControl;
if (ctrl == null)
Rectangle clipRect =
gxBuffer.Clip = new Region(clipRect);
gxBuffer.Clip = gxClipBounds;
(_backBuffer, e.ClipRectangle, e.ClipRectangle, GraphicsUnit.Pixel);
AlphaControl inherits from the
Control class and hides itself.
base.Visible = false;
It has a method
drawinternal which is called from its parent container (either
drawinteral method calls the
draw method of the derived classes. The
draw method paints/draws the control on the container using methods like
internal void DrawInternal(Graphics gx)
public virtual void Draw(Graphics gx)
What'll Be There in Part II and Part III
I shall post further articles:
- Part II will contain
- Part III will contain
AlphaListBox and other controls. Once those articles are posted, I shall update this article with the links.
Points of Interest
AlphaMobile controls have been a very interesting piece of development with a lot of scope to extend the functionalities and control collections. Some possible enhancements can be empowering controls with designer support. This can be very useful while using Alpha Datagrid controls or other list controls.
- 17th September, 2009: Initial post