Exercise: Create a 2-dimensional grid form, and code order button

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> WPF - Visual C#  (20 exercises)
Topic ==> Handling events  (3 exercises)
Level ==> Average difficulty
Course ==> WPF using Visual C#

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Create a window allowing users of your application to order a drink.  Depending on your energy levels, this could look simple or fancy:

Basic version of form Advanced version of form
The vanilla version The deluxe version

Both the examples above consist of a vertical stack panel containing a grid followed by a centrally aligned button.  The grid has 2 columns and either 2 or 4 rows, depending on which version you go for.

Attach code to your Place order button so that it displays what you've ordered (for the moment, ignore the sugars):

Order button results

When you click on the Place order button, you should see the drink that you've ordered.

 

Add a variable to hold the number of sugars ordered, to get a more complete message:

Order with sugars too

Display the name of the drink and the number of sugars ordered.

 

Finally, if you have time, add validation so that you get error messages if you leave the drink name blank or enter an invalid number of sugars:

No drinks ordered message No sugars specified message
Error if no drink name  Error if sugars invalid

Test that your application works, then close it down. 

This page has 0 threads Add post