Drag-and-Drop: Building the User Interface
Building a Windows Mobile application's UI is straightforwardsimply drag-and-drop the controls you want from the Toolbox
. Figure 6
shows three controls (Label, TextBox
, and Button
) dragged and dropped onto Form1
's design view. To change the look of each control (such as change its text, size, color, etc.), select the control and change its properties in the Properties
|Figure 6. Form1: Populating a Windows form with controls.|
With the UI built, you can switch to the code-behind of Form1 and write the code to wire up all the various controls on the form. In WindowsMobileApp, double-click on the Button control to handle its Click event so that when the user clicks on the button it will display the user's name.
Code the Click event of the Button control as shown in Listing 1.
Once the coding is done, you're ready to test the application. To test Windows Mobile applications, you have two choices:
Testing Using Emulators
- Using the emulators provided by the SDKs
- Using a real device
The SDKs for the various platforms include various emulators for you to test your Windows Mobile applications without needing to use a real device. For example, if your project is targeting the Windows Mobile 6 platform, you would see a list of emulators available for your testing (see Figure 7
Figure 7. Emulators: The list of emulators available for your testing.
Figure 8. Testing: You can test the application on an emulator.
Once you have selected an emulator to use, press F5 to deploy the application onto the emulator for testing (see "Figure 8).
Testing Using Real Devices
While most testing can be performed on the emulators, there are situations where you really need an actual device to fully test your application. For example, suppose your application uses infrared communicationyou'll need access to a device with that capability.
Testing your Windows Mobile application on real devices could not be easier. All you need is to:
- Download and install ActiveSync (or Windows Mobile Device Manager for Windows Vista).
- Connect your device to your development machine.
- Select Windows Mobile 6 Professional Device in Visual Studio 2008.
- Press F5 and the application will now be deployed to the device.