Categories
Uncategorized

The New Yorker’s Hallowe’en Cover and Why You Should Go to WinMoDevCamp

The New Yorker’s Hallowe’en Cover

I make sure to keep an eye on how technology pops up in mainstream non-geek culture because it’s a good way to gauge the techno-cultural zeitgeist and see how technologies are being received by the public at large. As techies, we’re all too happy to be early adopters and are willing to put up with usability problems, annoyances and extra work just to have the latest and greatest gear for its own sake. We have a tendency to forget that many non-techies don’t adopt technologies while they’re still new and need a techie mindset to use; they’ wait until technologies evolve to the point where the benefits outweigh the annoyances.

The current issue of The New Yorker has a Hallowe’en-themed cover that hints at how much smartphones have worked their way into everyday people’s lives:

New Yorker Halloween Cover

Here’s a closeup:

New Yorker Halloween Cover closeup

(I’ll bet that at least one of you went out Saturday night trick-or-treating and checked your smartphone.)

The practical upshot of all this: the mobile platform is in your future. It’s the one that people take everywhere and it’s growing in power in leaps and bounds the way desktop (and later, laptop) computers did in the ‘80s and ‘90s.

WinMoDevCamp

WinMoDevCamp banner

Speaking of mobile platforms, we’re holding a full-day workshop on Windows Phone development called WinMoDevCamp Toronto next Wednesday, November 11th  from noon to 9 p.m. at the Microsoft Mississauga offices (1950 Meadowvale Boulevard). It’s free of charge and your chance to learn how to develop applications for Windows Phone.

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

WinMoDevCamp: Save the Date – November 11th!

WinMoDevCamp banner

On Wednesday, November 11th, we’ll be hosting the Toronto-area WinMoDevCamp at Microsoft Canada’s headquarters! It’ll be the fifth in a series of worldwide “Camp” style workshops focusing on developing applications for Windows Mobile (including the upcoming Windows Mobile 6.5).

WinMoDevCamp – short for Windows Mobile Developer Camp – was inspired by events like BarCamp, SuperHappyDevHouse and the original iPhoneDevCamp. It’s a free-of-charge get-together where mobile developers, web developers, .NET developers, UI designers, testers, device manufacturers and Canadian mobile carriers gather, team up and work in ad-hoc mobile development projects for the day.

You’ll get to:

  • Create new applications for the Windows Mobile Platform
  • Meet and work side-by-side with people from the Microsoft Mobile Developer Experience team
  • Migrate existing mobile apps from the iPhone, BlackBerry and Palm Pre to the Windows Mobile platform
  • Create applications to support Windows Enterprise Applications
  • Meet with representatives from Canadian mobile phone companies, including Bell, Rogers, Telus and WIND
  • Test and optimize applications for Windows Mobile 6.5

The event is free-as-in-beer (in other words, it costs nothing to attend), and you’ll be able to sign up to attend soon – watch this space!

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

The “Developing for the Microsoft-Based Platform” Track at TechDays Canada

Microsoft TechDays Canada 2009: 2 days - 7 cities - 5 tracks - 40 sessions - plus more!

In planning this year’s TechDays conference, we made some significant changes to the developer tracks: they were reformulated into:

  • A “tools and techniques” track, called Developer Fundamentals and Best Practices, for which my friend and fellow Developer Evangelist John Bristowe is the track lead
  • A “technologies” track, called Developing for the Microsoft-Based Platform, which I lead.

As the track lead for the Developing for the Microsoft-Based Platform track at TechDays Canada 2009 conference, I thought I’d take the time to talk about it and praise its virtues.

Designing the Track

Each track lead has the responsibility of designing his or her track. We pored over all the sessions from TechEd North America 2009, consulted with developers or IT pros for their opinions on what topic they’d like covered and came up with a selection of 8 sessions for each track.

When choosing my sessions, I kept these philosophies in mind:

  • TechDays is about current tools, technologies and techniques. That means talking about stuff you can get your hands on and use in production right now: Visual Studio 2008, .NET 3.5, SQL Server 2008, and so on. Visual Studio 2010, .NET 4.0 and Azure are fascinating tools and tech, but they’re not yet on the market, so they’re not in TechDays. We made a few exceptions for a couple of things that are coming out right around now: version 3.0 of Silverlight and the Expression suite and Windows 7.
  • TechDays is about giving the audience the biggest bang for the buck. It’s more than simply taking the content from the TechEd North America conference (which has a steep registration fee and you have to also factor in the costs of flying to and staying in New Orleans) and bringing it close to home with local speakers and a reasonable price tag. It’s also about choosing the content that best serves an an audience that uses Microsoft tools and tech in their day-to-day work. There’s no point in rehashing presentations that the audience has already seen a dozen times before, and neither does it do any good to cover topics that are interesting but impractical. I tried to strike a balance — in choosing the sessions for my track, I kept this question in mind: What sort of things will this audience be using that they aren’t using yet?
  • TechDays is more than just throwing random information at the audience. A track needs to be more than just a collection of sessions simply thrown together. It works best if it’s a set of sessions whose topics fit together to form a cohesive whole, almost as if telling a story. While picking out the track’s sessions and arranging them, I tried to set things up in such a way to best show the possibilities that open up when you develop on the Microsoft-based platform. 

The Developing for the Microsoft-Based Platform Track

The Developing for the Microsoft-Based Platform track breaks down into four topic areas, as shown in the diagram below:

platform_track_chart

The topic areas are:

  1. Day 1 morning: Rich UIs
  2. Day 1 afternoon: Client Tech
  3. Day 2 morning: ASP.NET MVC
  4. Day 2 afternoon: Web Services

They’re explained in greater detail below.

Day 1 – Front End: User Interface and Experience

Day 1 of the Developing for the Microsoft-Based Platform is about building the front end, that layer of our applications with which the user interacts, and about giving the user the best experience possible.

The morning will be an introduction to the latest version – version 3 – of our rich interface technology Silverlight and our rich interface-building tool, Expression Blend. In the afternoon, we’ll shift the focus to building client technology by looking at the PRISM guidelines for building applications with modular Silverlight- and WPF-based front ends and the API code pack for building .NET applications that take advantage of Windows 7’s new UI features.

The tools and technologies covered on Day 1 are:

  • Silverlight 3
  • Expression Blend 3
  • WPF
  • Windows 7
  • Windows 7 API Code Pack for the .NET Framework
  • Windows Mobile

Day 1 Morning: Rich UIs

Track Introduction
Presented by Joey deVilla
9:00 a.m. – 9:15 a,m.


Session 1: What’s New in Silverlight 3
Presented by Cory Fowler
9:15 a.m. – 10:30 a.m.
Cory Fowler Rich internet applications just got richer! Silverlight 3 is packed with new features and improvements that your users will notice, from pixel shaders to perspective 3D to animation enhancements to bitmap APIs to HD video. We think you’ll also be impressed by the features for developers, such as the updated style model, data binding improvements, better resource handling, and a tuned-up Web services stack. In this session, we’ll explore new features of Silverlight 3 as we build a Silverlight-based application using Expression Blend 3 and Visual Studio.

Session 2: Expression Blend for Developers
Presented by Barry Gervin
10:50 a.m. = 12:05 a.m.
Barry Gervin Not a designer? Overwhelmed by Expression Blend? Not a problem! We’ll show you how to use Expression Blend to create advanced and polished user interfaces for business applications, consumer applications, multimedia projects, games or anything in between. We’ll cover features of Expression Blend from a developer’s perspective and show how it works in tandem with Visual Studio throughout the development process. You’ll learn how to create professional-looking user interfaces and visual elements – even if you don’t think of yourself as an interface designer.

Day One Afternoon: Client Tech

Session 3: Building Modular Applications Using Silverlight and WPF
Presented by Rob Burke
1:10 p.m. – 2:25 p.m.
Rob Burke How do you build extensible and maintainable line-of-business applications in Silverlight and Windows Presentation Foundation (WPF)? How do you design and code to handle real-world complexity? Composite Application Guidance (a.k.a. "PRISM") offers guidance, libraries and examples – in small, free-standing, digestible chunks – that you can use to build applications with rich user interfaces that are also easier to maintain and extend. You’ll learn how to compose complex UIs from simpler views, integrate loosely coupled components with "EventAggregator" and "Commands", develop independent modules that can be loaded dynamically, and share code between Silverlight and WPF clients.

Session 4: Optimizing Your Apps for the Windows 7 User Experience
Presented by Anthony Vranic
2:45 p.m. – 4:00 p.m.
Anthony Vranic This session will show you the Windows 7 APIs that will let your applications – and your users – get the full Windows 7 experience. Learn about new extensibility methods to surface your application’s key tasks. Discover how enhancements to the taskbar, Start Menu, thumbnails, desktop elements, the Scenic Ribbon, Federated Search and Internet Explorer 8 provide new ways for you to delight your users and help make them more productive. If you want to give your users the best Windows 7 experience, this session is for you!

Bonus Session: Taking Your Application on the Road with Windows Mobile® Software
Presented by Mark Arteaga and Anthony Bartolo
4:20 p.m. – 5:30 p.m.

Mark Arteaga and Anthony Bartolo As a developer of .NET-based applications, you can extend your desktop software to the Windows Mobile-based platform using the tools available within Visual Studio®, the Windows Mobile SDK and the .NET Compact Framework. This session will give you an overview of how Windows Mobile lets you use your existing infrastructure, business logic, and desktop code on a mobile device to innovate and help solve business problems. We’ll show you how to use the familiar Microsoft .NET Framework and .NET-based programming languages like Visual C#® development tool. You will also learn about new features in Windows Mobile 6.5 such as the Gesture APIs and the Widget Framework and how to use them appropriately. With the launch of Windows Marketplace for Mobile upon us, this session will help you take the next step for application testing and submission.

Day 2 – Back End: Programming Frameworks and Principles

On Day 2, the track moves to the back end, focusing on server-side programming tools and technologies, and even wandering into the area of technique.

The morning’s sessions concern themselves with the new option for developing web applications using ASP.NET: ASP.NET MVC, the alternative framework based on the Model-View-Controller pattern, in the same spirit of such frameworks as Ruby on Rails, Django and CakePHP. The afternoon will be about writing web services using various Microsoft technologies.

The tools, technologies and techniques covered on Day 2 are:

  • ASP.NET MVC
  • The SOLID principles of object-oriented design
  • WCF
  • REST (REpresentational State Transfer)
  • SharePoint

Day 2 Morning: ASP.NET MVC

Track Introduction
Presented by Joey deVilla
9:00 a.m. – 9:15 a,m.

Session 1: Introducing ASP.NET MVC
Presented by Colin Bowern
9:15 a.m. – 10:30 a.m. 
Colin Bowern You’ve probably heard the buzz about Model-View-Controller (MVC) web frameworks. They’re all the rage because they combine speed, simplicity, control…and fun. ASP.NET MVC is Microsoft’s MVC web framework, and in this session, we’ll talk about the MVC pattern, explain the ideas behind ASP.NET MVC and walk through the process of building an application using this new web framework. We’ll also cover several techniques to get the most out of ASP.NET MVC and deliver web applications quickly and with style.

Session 2: SOLIDify Your Microsoft ASP.NET MVC Applications
Presented by Bruce Johnson
10:50 a.m. – 12:05 a.m.
Bruce Johnson Object-oriented programming makes it easier to manage complexity, but only if you do it right. The five SOLID principles of class design (one for each letter) help ensure that you’re writing applications that are flexible, comprehensible and maintainable, and we’ll explain and explore them in this session. We’ll start with a brittle ASP.NET MVC application that’s badly in need of refactoring and fix it by applying the SOLID principles. This session is a good follow-up for Introducing ASP.NET MVC, but it’s also good for developers of ASP.NET MVC looking to improve their code – or even if you’re not planning to use ASP.NET MVC. The SOLID principles apply to programming in any object-oriented language or framework.

Day 2 Afternoon: Web Services


Session 3: Building RESTful Services with WCF
Presented by Bruce Johnson
1:10 p.m. – 2:25 p.m.
Bruce JohnsonREST (REpresentational State Transfer) is an architectural style for building services, and it’s the architectural style of the web. It’s been popular outside the world of Microsoft development for a long time, but it’s quickly becoming the de facto standard inside as well. Windows Communication Foundation (WCF) makes it simple to build RESTful web services, which are easy to use, simple and flexible. In this session, we’ll cover the basics of REST and the show you how to build REST-based, interoperable web services that can be accessed not just by Microsoft-based web and desktop applications, but anything that can communicate via HTTP from an Ajax client to a feed readers to mobile device to applications written using other languages and frameworks such as PHP, Python/Django or Ruby/Rails.

Session 4: Developing and Consuming Services for SharePoint
Presented by Reza Alirezaei
2:45 p.m. – 4:00 p.m.
Reza Alirezaei The world gets more service-oriented every day, and with that comes the demand to integrate all kinds of services, including those from SharePoint. This session introduces SharePoint as a developer platform and provides an overview of how you can build and deploy custom services with it. The focus will be on developing ASP.NET and Windows Communication Foundation services for SharePoint as well as building a Silverlight client to consume them.

This article also appears in Canadian Developer Connection.

Categories
Uncategorized

TechDays Vancouver: More Scenes from the “Platform” Track

Two out of three of this afternoon’s sessions in my track at the TechDays conference – Developing for the Microsoft-Based Platform — were presented by Anthony Vranic, an independent consultant who used to be a Microsoft developer evangelist. His sessions:

  • Building Modular Applications Using Silverlight and WPF
  • Optimizing Your Apps for the Windows 7 User Experience

Anthony Vranic presenting at TechDays Vancouver 2009

Next up were Anthony Bartolo and Mark Arteaga, who were there to present the session Taking Your Application on the Road with Windows Mobile Software, in which they showed us things that people think Windows Mobile can’t do.

arteaga_bartolo_1

Yup, that’s The Beatles: Rock Band beside Anthony – this was a session where you could leave with a prize! They gave away XBox games to people who answered skill- and mobile market knowledge-testing questions correctly.

arteaga_bartolo_2

They gave The Beatles: Rock Band to the person working on the most interesting Windows Mobile app, as judged by audience applause. It went to the gentleman in the photo below on the right, who wrote a currency exchange application that watches exchange markets for the ideal time and buys foreign currencies then. He uses it to send money home to New Zealand within taking a bath on the exchange rate.

winner

As I write this, it’s 5:45 p.m. Pacific, which means that the next event, Demo Ignite Camp, is just over an hour away.

Categories
Uncategorized

Windows Mobile Case Study: Porting Amplitude to WinMo

HTC phone with Amplitude on screen (simulated)

The Windows Mobile Blog points to an MSDN article covering how Amplitude, an application for the iPhone, was ported to Windows Mobile.

Here’s a quick description of Amplitude, which is developed by Gripwire, a mobile and social app company based in Seattle, courtesy of the Windows Mobile Blog:

Amplitude picks up any sound in a user’s surroundings through the microphone and then amplifies the sound, rendering it into a rich graphical representation on the device. Amplitude can be used to amplify any sounds, such as human or animal heartbeats, that usually wouldn’t be picked up by the human ear. Amplitude provides a cool user interface featuring an oscilloscope that allows users to view and visually quantify, signal voltages, as you can see the volume of the sound that you are listening to.

The MSDN article on the Amplitude porting project covers a lot of ground, including:

Whether you’re thinking of expanding your iPhone application to other platforms or starting a new Windows Mobile app project, you’ll find this case study packed with useful information and links. I’m going to expand on some of the topics covered in the article in future posts on this blog.

And don’t forget – there’s the Race to Market Challenge, in which you’re automatically entered whenever you submit a mobile app to Windows Marketplace for Mobile. Here’s a quick reminder of what Race to Market is all about:

Categories
Uncategorized

The “Race to Market Challenge” for Windows Mobile

This article also appears in Canadian Developer Connection.

The Race to Market Challenge

Here’s a quick little video that explains what the just-announced Race to Market challenge is all about:

If you’ve been thinking about developing for Windows Mobile, now’s the time! We’re now accepting submissions of applications for Windows Marketplace for Mobile, the on-phone store where people with Windows Mobile phones can buy and install mobile applications easily. Better still, we’re making it a contest – submit your Windows Mobile app between now and 11:59 p.m. on December 31st and you’ll automatically be entered in the Race to Market Challenge where you’ll have a chance to win one of 4 Surface tables (developer edition, of course) like the one pictured below with the dashing Developer Evangelist…

surface_pdc

…along with a lot of online marketing and promotion for your application and a really cool trophy.

Winning applications will fall into one of these categories:

  • Most downloaded
  • Most valuable (where “value” is the number of downloads multiplied by the price)
  • Most useful, as judged by a Microsoft panel
  • Most playful, as judged by a Microsoft panel

The Race to Market Challenge runs from now until December 31st, and the sooner you get started, the more likely you shot at one of the grand prized. For full details about the contest, visit mobilethisdeveloper.com.

Getting Started with Windows Mobile Development

Between now and the end of the contest, I’ll be posting articles on Windows Mobile development and the Race to Market Challenge. In the meantime, here are some tips that should help you get started.

What You Need

Here’s a snippet from an earlier article of mine that shows you what you need in order to get started with Windows Mobile development. In order to build an application for Windows Mobile 6, you’ll need the following things:

Visual Studio 2008, Professional Edition or higher
visual_studio_2008_pro
This is the development environment. It’s not the only one that you can use to develop Windows Mobile apps, but it’s the one we’re using.

You can also use Visual Studio 2005 – if you do so, Standard Edition or higher will do. If you don’t have Visual Studio, you can download a trial version of Visual Studio 2008.
 

The Windows Mobile 6 SDKs
gear_icon
 
The Windows Mobile 6 SDKs contain the templates for building Windows Mobile 6 projects and emulators for various Windows mobile phones.

There are two such SDKs to choose from:

  • The Standard SDK. The general rule is that if the device doesn’t have a touch screen, its OS is Windows Mobile 6 Standard, and this is the SDK for developing for it.
  • The Professional SDK. The general rule is that if the device has a touch screen, its OS is Windows Mobile 6 Professional, and this is the SDK for developing for it.

    I recommend downloading both SDKs. You never know where you’ll deploy! 

  • .NET Compact Framework 3.5 Redistributable
    dotnet_logo
     
    The .NET Compact Framework 3.5 Redistributable is the version of the .NET framework for mobile devices. It only needs to be sent to the device once.
    A Windows Mobile 6 Device
    palm_treo_pro
     
    You can get by in the beginning with just the emulators, but you’ll eventually want to try out your app on a real phone. I’m using my phone, a Palm Treo Pro.

    As the saying goes, “In theory, there is no difference between theory and practice; in practice, there is.”

    The mobile device syncing utility that works with your operating system
    windows_mobile_device_center_icon
    If you’ve got a Windows Mobile 6 device, you’ll need the application that connects your mobile phone to your OS:

  • For Windows 7 and Vista, use Windows Mobile Device Center.
  • For Windows XP and Server 2003, use ActiveSync.
  • Previous Articles on Windows Mobile Development

    Here are links to my earlier articles on Windows Mobile development:

    I’ll be posting more soon, but these should help you get up and running in the meantime.

    If you’ve got any questions or comments about Windows Mobile development or the Race to Market Challenge, feel free to drop me a line or leave a note in the comments!

    Categories
    Uncategorized

    Upwardly Mobile, Part 3: Exploring Windows Mobile 6’s Built-In UI Controls

     Mad Mobile: More Windows Mobile 6 example code from the guy who blogs at Global Nerdy

    In my previous article in Upwardly Mobile, the ongoing article series in which I look as various aspects of Windows Mobile 6 development, I showed you a simple application that made use of a couple of user interface controls. In this article, we’ll take a closer look at some of the user interface controls by way of the steak-and-cocktails lifestyle of the characters on the TV series Mad Men.

    (In case you’re not familiar with Mad Men, it’s a dramatic TV series set in the early 1960s whos emain characters are advertising executives working at an agency in New York. It was the age of three-martini steak lunches, which serves as the inspiration for the example application in this article.)

    Introducing Beef ‘N’ Booze

    The application that we’ll build is called Beef ‘N’ Booze. It has no real function other than to demonstrate the use of some of the controls that come with Windows Mobile 6, and do so in a more entertaining way that you’d normally find in a book.

    Here’s what the app will look like on startup:

    beef_screen_1

    The app has a single form and that form is filled completely with a tab control with two tab pages: Beef and Booze. The Beef page lets you choose the “doneness” of your steak as well as a selection of side dishes. Once you’ve made your choices, you click the Place Order button to see a message box containing a summary of your order:

    beef_screen_2

    Clicking on the Booze tab takes you to the Booze page, where you can place an order from a selection of cocoktails. You can also specify the number of cocktails you want to order and how strong you want the bartender to make them:

    booze_screen_1

    When you’ve made your drink choices, you click on the Place Order button to see a message box summarizing your drink order:

    booze_screen_2

    That’s the app in a nutshell. Remember that the idea behind Beef ‘N’ Booze isn’t to make something useful; it’s to demonstrate Windows Mobile’s built-in user controls and give you a chance to explore them. With that knowledge and a little practice, you can eventually build apps that actually do something.

    TabControl and TabPages

    One of the tricks to compensate for the limited screen “real estate” on a mobile device is to break up an application into pages. The simplest “out of the box” way to do this with Windows Mobile is to use a TabControl, which is a container that holds one or more TabPage controls. Each TabPage is itself a container that can hold other controls.

    In Beef ‘N’ Booze, I created a TabControl named tabMain, which holds two TabPages:

    • tpgBeef, whose Text property is set to Beef. It will contain the controls for placing and order for a steak and side dishes.
    • tpgBooze, whose Text property is set to Booze. It will contain the controls for ordering cocktails.

    tabcontrol_tabpages

    One convenient thing about using TabControls is that the tabbed pages work inside Visual Studio’s form editor. To view and edit a given TabPage, you click on its tab; it becomes the topmost page and you can add, move and remove controls from it.

    Buttons

    The Beef page has a single button, btnBeef, that when clicked, causes a message box to display the user’s order for steak and side dishes. The Booze page has a similar button, btnBooze, except that it causes a message box to display the user’s cocktail order.

    buttons

    We’ll draw btnBeef on the tpgBeef page and btnBooze on the tpgBooze page. The next step is to create event handlers for both buttons. The easiest way to do this is to select each button and then use the Events view in the Properties window, and double-clicking on the Click event for each button. Here’s a screenshot of me doing that for btnBeef – Visual Studio responds by auto-magically creating a handler named btnBeef_Click:

    btnBeef

    Creating event handlers for btnBeef and btnBooze creates these empty methods in the code for the form:

    private void btnBeef_Click(object sender, EventArgs e)
    {
    }
    
    private void btnBooze_Click(object sender, EventArgs e)
    {
    }

    While I do like the “magic” provided by Visual Studio, I also feel that you should know what’s going on behind the scenes. How are the btnBeef_Click() and btnBoozeClick() methods attached to the btnBeef and btnBooze controls? It’s taken care of in the Designer code for the form, in which the layout and events for controls on the form is defined. Here’s the chunk of code that concerns with btnBeef’s properties and events:

    this.btnBeef.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular);
    this.btnBeef.Location = new System.Drawing.Point(165, 181);
    this.btnBeef.Name = "btnBeef";
    this.btnBeef.Size = new System.Drawing.Size(111, 28);
    this.btnBeef.TabIndex = 8;
    this.btnBeef.Text = "Place Order";
    this.btnBeef.Click += new System.EventHandler(this.btnBeef_Click);

    When I added a Click event to btnBeef through the Properties window, Visual Studio generated the name btnBeef_Click for the event handler, added a blank btnBeef_Click() method to the form’s code and connected the event to the handler in the form’s Designer code with this line:

    this.btnBeef.Click += new System.EventHandler(this.btnBeef_Click);

    When the user clicks btnBeef, we want to call a method named OrderBeef(), which will collect the data from the controls on tpgBeef, format it into something human-readable and then display the results in a message box. When the user clicks btnBooze, we want to call a method name OrderBooze(), which will do something similar, but for the user’s cocktail order. Here’s what the resulting event handler code should look like:

    private void btnBeef_Click(object sender, EventArgs e)
    {
        OrderBeef();
    }
    
    private void btnBooze_Click(object sender, EventArgs e)
    {
        OrderBooze();
    }

    We’ll define OrderBeef() and OrderBooze() over the next couple of sections, as we explore the controls.

    Radio Buttons

    Radio buttons are controls you use when:

    • You want the user to choose one (and only one) item from a selection of items
    • You want the user to be able to see the complete selection of items immediately

    The name “radio buttons” comes from the radio buttons from older radios, such as those in older cars, which let you choose from a number of pre-set radio stations. Selecting one button would change the tuning to the corresponding radio station and de-select the currently selected button:

    car_radio_buttons

    Radio buttons are grouped together by putting them inside the same container control, such as a panel, or in the case of this particular application, a TabPage. Selecting a radio button de-selects all the other radio buttons occupying the same container control.

    The diagram below shows the radio buttons on tpgBeef and the names I assigned to them:

    radio_buttons

    Here’s my first iteration of OrderBeef(), which shows you how to determine which radio button is selected by checking each one’s Checked property. Once that’s done, it displays the resulting choice in a message box:

    private void OrderBeef()
    {
        StringBuilder order = new StringBuilder("Steak: ");
    
        if (rdoRare.Checked)
        {
            order.AppendLine("Rare");
        }
        else if (rdoMediumRare.Checked)
        {
            order.AppendLine("Medium Rare");
        }
        else if (rdoMedium.Checked)
        {
            order.AppendLine("Medium");
        }
        else if (rdoMediumWell.Checked)
        {
            order.AppendLine("Medium Well");
        }
        else if (rdoWellDone.Checked)
        {
            order.AppendLine("Well Done");
        }
        else
        {
            order.AppendLine("Chef's choice");
        }
    
        MessageBox.Show(order.ToString());
    }

    Checkboxes

    Checkboxes are useful when:

    • You want the user to select zero, one or more items
    • You want the user to be able to see the complete selection of items immediately

    The diagram below shows the checkboxes on tpgBeef and the names I assigned to them:

    checkboxes

    Here’s my second iteration of OrderBeef(), which adds some code to check to see which side dishes the user ordered. As with radio buttons, we’re using the Checked properties, but for the checkboxes:

    private void OrderBeef()
    {
        StringBuilder order = new StringBuilder("Steak: ");
        int numSides = 0;
    
        if (rdoRare.Checked)
        {
            order.AppendLine("Rare");
        }
        else if (rdoMediumRare.Checked)
        {
            order.AppendLine("Medium Rare");
        }
        else if (rdoMedium.Checked)
        {
            order.AppendLine("Medium");
        }
        else if (rdoMediumWell.Checked)
        {
            order.AppendLine("Medium Well");
        }
        else if (rdoWellDone.Checked)
        {
            order.AppendLine("Well Done");
        }
        else
        {
            order.AppendLine("Chef's choice");
        }
    
        order.AppendLine("Sides:");
    
        if (chkCreamedSpinach.Checked)
        {
            order.AppendLine("Creamed Spinach");
            ++numSides;
        }
    
        if (chkFrites.Checked)
        {
            order.AppendLine("Frites");
            ++numSides;
        }
    
        if (chkMushrooms.Checked)
        {
            order.AppendLine("Mushrooms");
            ++numSides;
        }
    
        if (numSides == 0)
        {
            order.AppendLine("None");
        }
    
        MessageBox.Show(order.ToString());
    }

    Comboboxes

    comboboxes

    For the Booze page, I thought I’d use a different way to let the user select one item from a selection of many: a Combobox with its DropDownStyle property set to DropDownList and containing a number of cocktail names. The method below does the following:

    • Sets the Combobox’s DropDownStyle property to DropDownList, which means that the user cannot just type in any value into the list’s text portion, but can only select from items in the list.
    • Adds a number of cocktail names to the list.
    • Sets the list so that the first item is selected.

    public void InitializeCocktailControls()
    {
        cboCocktail.DropDownStyle = ComboBoxStyle.DropDownList;
        cboCocktail.Items.Add("Bloody Caesar");
        cboCocktail.Items.Add("Bloody Mary");
        cboCocktail.Items.Add("Martini");
        cboCocktail.Items.Add("Rye and Ginger");
        cboCocktail.Items.Add("Vodka Tonic");
        cboCocktail.SelectedIndex = 0;
    }

    If I wanted to, I could’ve set the DropDownStyle and the collection of items in the ComboBox in the Properties window.

    I placed a call to InitializeCocktailControls() inside the form’s constructor:

    public frmMain()
    {
        InitializeComponent();
        InitializeCocktailControls();
    }

    And here’s my first iteration of OrderBooze(), which displays a message box showing which cocktail the user ordered. It makes use of the ComboBox’s SelectedItem property:

    private void OrderBooze()
    {
        StringBuilder order = new StringBuilder("Cocktail: " +
                                cboCocktail.SelectedItem.ToString() + 
                                "\n");
    
        MessageBox.Show(order.ToString());
    }

    Numeric Up/Downs

    Numeric Up/Downs are useful when:

    • You want to restrict user input to numeric values only
    • You want to restrict those numeric values to a specific range

    numeric_updowns

    Here’s the second iteration of InitializeCocktailControls(), which adds code to initialize the numeric up/down nudCocktail in the following ways:

    • Restricting the possible values to the range of 1 through 10
    • Setting the up/down increment to 1 – if the user clicks the “up” button, the value contained within goes up by 1, if the user clicks the “down” button, the value contained within goes down by 1.
    • Setting the initial value to 1

    public void InitializeCocktailControls()
    {
        cboCocktail.DropDownStyle = ComboBoxStyle.DropDownList;
        cboCocktail.Items.Add("Bloody Caesar");
        cboCocktail.Items.Add("Bloody Mary");
        cboCocktail.Items.Add("Martini");
        cboCocktail.Items.Add("Rye and Ginger");
        cboCocktail.Items.Add("Vodka Tonic");
        cboCocktail.SelectedIndex = 0;
    
        nudCocktail.Minimum = 1;
        nudCocktail.Maximum = 10;
        nudCocktail.Increment = 1;
        nudCocktail.Value = 1;
    }

    Here’s the OrderBooze() method, featuring an additional line of code to display the number of drinks the user ordered. The value contained within nudCocktail is taken from its Value property:

    private void OrderBooze()
    {
        StringBuilder order = new StringBuilder("Cocktail: " +
                                cboCocktail.SelectedItem.ToString() + 
                                "\n");
        order.AppendLine("Quantity: " + nudCocktail.Value.ToString());
    
        MessageBox.Show(order.ToString());
    }

    Trackbars

    Another way to get numeric value input from the user is to use a Trackbar control. While Trackbars don’t display their corresponding numeric values like Numeric Up/Downs, they have a couple of advantages:

    • They’re larger and more “finger-friendly” than Numeric Up/Downs
    • They give the user a visual cue of where the current value is in relation to the minimum and maximum values

    trackbars

    In the screenshot above, you can see that I’ve augmented the Trackbar with by putting a couple of label controls just below it: Lame, Decent, and Hardcore.

    Here’s another iteration of InitializeCocktailControls(), with code to initialize the Trackbar with the following properties:

    • The leftmost position on the Trackbar corresponds to the value 0
    • The rightmost position on the Trackbar corresponds to the value 10
    • The smallest step you can make in either direction, up or down, is 1
    • Large steps, which you get by clicking to the right or left of the current slider position, change the value in steps of 5
    • The initial value of the Trackbar is 5

    public void InitializeCocktailControls()
    {
        cboCocktail.DropDownStyle = ComboBoxStyle.d;
        cboCocktail.Items.Add("Bloody Caesar");
        cboCocktail.Items.Add("Bloody Mary");
        cboCocktail.Items.Add("Martini");
        cboCocktail.Items.Add("Rye and Ginger");
        cboCocktail.Items.Add("Vodka Tonic");
        cboCocktail.SelectedIndex = 0;
    
        nudCocktail.Minimum = 1;
        nudCocktail.Maximum = 10;
        nudCocktail.Increment = 1;
        nudCocktail.Value = 1;
    
        tbrCocktail.Minimum = 0;
        tbrCocktail.Maximum = 10;
        tbrCocktail.SmallChange = 1;
        tbrCocktail.LargeChange = 5;
        tbrCocktail.Value = 5;
    }

    Here’s OrderBooze(), with an additional line to display the user’s preferred drink strength, which is derived from the Trackbar’s Value property:

    private void OrderBooze()
    {
        StringBuilder order = new StringBuilder("Cocktail: " +
                                cboCocktail.SelectedItem.ToString() + 
                                "\n");
        order.AppendLine("Quantity: " + nudCocktail.Value.ToString());
        order.AppendLine("Strength: " + tbrCocktail.Value.ToString());
    
        MessageBox.Show(order.ToString());
    }

    Putting It All Together

    Here’s the complete code behind the single form in Beef ‘N’ Booze:

    using System;
    using System.ComponentModel;
    using System.Text;
    using System.Windows.Forms;
    
    namespace BeefNBooze
    {
        public partial class frmMain : Form
        {
            public frmMain()
            {
                InitializeComponent();
                InitializeCocktailControls();
            }
    
            public void InitializeCocktailControls()
            {
                cboCocktail.DropDownStyle = ComboBoxStyle.DropDownList;
                cboCocktail.Items.Add("Bloody Caesar");
                cboCocktail.Items.Add("Bloody Mary");
                cboCocktail.Items.Add("Martini");
                cboCocktail.Items.Add("Rye and Ginger");
                cboCocktail.Items.Add("Vodka Tonic");
                cboCocktail.SelectedIndex = 0;
    
                nudCocktail.Minimum = 1;
                nudCocktail.Maximum = 10;
                nudCocktail.Increment = 1;
                nudCocktail.Value = 1;
    
                tbrCocktail.Minimum = 0;
                tbrCocktail.Maximum = 10;
                tbrCocktail.SmallChange = 1;
                tbrCocktail.LargeChange = 5;
                tbrCocktail.Value = 5;
            }
    
            private void btnBeef_Click(object sender, EventArgs e)
            {
                OrderBeef();
            }
    
            private void btnBooze_Click(object sender, EventArgs e)
            {
                OrderBooze();
            }
    
            private void OrderBeef()
            {
                StringBuilder order = new StringBuilder("Steak: ");
                int numSides = 0;
    
                if (rdoRare.Checked)
                {
                    order.AppendLine("Rare");
                }
                else if (rdoMediumRare.Checked)
                {
                    order.AppendLine("Medium Rare");
                }
                else if (rdoMedium.Checked)
                {
                    order.AppendLine("Medium");
                }
                else if (rdoMediumWell.Checked)
                {
                    order.AppendLine("Medium Well");
                }
                else if (rdoWellDone.Checked)
                {
                    order.AppendLine("Well Done");
                }
                else
                {
                    order.AppendLine("Chef's choice");
                }
    
                order.AppendLine("Sides:");
    
                if (chkCreamedSpinach.Checked)
                {
                    order.AppendLine("Creamed Spinach");
                    ++numSides;
                }
    
                if (chkFrites.Checked)
                {
                    order.AppendLine("Frites");
                    ++numSides;
                }
    
                if (chkMushrooms.Checked)
                {
                    order.AppendLine("Mushrooms");
                    ++numSides;
                }
    
                if (numSides == 0)
                {
                    order.AppendLine("None");
                }
    
                MessageBox.Show(order.ToString());
            }
    
            private void OrderBooze()
            {
                StringBuilder order = new StringBuilder("Cocktail: " +
                                        cboCocktail.SelectedItem.ToString() + 
                                        "\n");
                order.AppendLine("Quantity: " + nudCocktail.Value.ToString());
                order.AppendLine("Strength: " + tbrCocktail.Value.ToString());
    
                MessageBox.Show(order.ToString());
            }
    
        }
    }

    Download, Go Forth and Noodle!

    It’s one thing to read about Windows Mobile 6’s built-in user interface controls, but something else entirely to make use of them. If you’re feeling ambitious, start a new project and rebuild Beef ‘N’ Booze (or a similar app that lets you explore the controls) yourself. Or, if you’d like, download my project files by clicking the link below, play with the app, make changes and learn. No matter which route you take, the best way to learn to is fire up Visual Studio and get coding!

    Download icon Download the Beef ‘N’ Booze project (Visual Studio 2008 SP1, 15K .zip file)