WPF - Visual C# | Datagrids exercise | Linked listboxes and datagrids - a full(ish) application

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).

Software ==> WPF - Visual C#  (20 exercises)
Version ==> Any version of WPF
Topic ==> Datagrids  (2 exercises)
Level ==> Harder than average
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

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.

This is perhaps an exercise to begin now, but finish on another day!

First run the SQL script in the above folder if necessary to create a database, if you haven't already done so.  You'll also need to add the images in the above folder into your project.

To start, first create a start-up menu as follows:

Start-up menu buttons

When you click on the Exit button, your menu should close; when you click on the Bouncing Ball button, you should get a suitable animation (the contents of which are left to your imagination!).


When you click on View packs, you should see a list box listing out all of the Top Trumps packs taken from the tblPack table:

Listbox listing top trump packs

You should be able to click on any item in the list, then click on OK to select it (the Cancel button should just return you to the main menu).


If you select OK without choosing a pack, you should see an error:

Error if no item chosen

You should display a suitable message if no item is chosen.


If you choose a pack and select OK, you should see the details for this pack:

Animals pack window

The image and categories come from the tblPack record chosen in the previous menu.

If you click on the Show a card button, you should see the first card in the relevant pack:

Sheapey Top Trumps card

See below for some notes on how this should work.

The categories and scores for the window on the previous page should come from the underlying data (you may find the view already created called vwCard useful at this point).  The previous and next record buttons should take you to the previous and next card record for this pack (this is the only part of the model answer which isn't coded).

For all of the windows, make sure that the Cancel buttons return you to the previous window or main menu, as you deem appropriate.

If you have time, you could try:

  • disabling the previous/next record buttons at the appropriate times in the above window;
  • adding a menu and toolbar to your system;
  • moving all formatting to styles, so that the XAML contains only the control definitions and binding.

Or you could try having a go at the real system waiting for you in the office ... !

This page has 0 threads Add post