WISE OWL EXERCISES
WPF - VISUAL C# EXERCISES
WPF - Visual C# | Handling events 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 relevant Wise Owl course (sadly, only in the UK for now).
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:
|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):
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:
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:
|Error if no drink name||Error if sugars invalid|
Test that your application works, then close it down.