Lesson 03.1: Creating the Solution and Game Screen

 

In this lesson, we’ll start to create the game. We’ll create the “solution”, to hold the files that will make the game, and we’ll create the beginnings of the game screen.

 

Summary

  • A “solution” is the files that make up a program.
  • A “solution” has at least one “project” – although, it can have more.
  • A “project” has related files that are grouped together, to make them easier to find/work with.

 

  • A “WPF project” holds a program’s screens, using XAML files.
  • “XAML” is used to define the format of “controls” (grids, buttons, text, etc.) on the screens of a program.
  • XAML controls are declared with “tags”.
  • XAML controls need opening tagĀ  and closing tags.
    • For example: “<RowDefinition Height=”Auto”>” and “</RowDefinition>”
  • Some tags have “attributes” that you can set in the opening tag (such as the “Title” of a Window).
  • Sometimes, XAML controls are “child” controls. They are more detailed information for the “parent” control, and must be placed between the “parent” controls opening and closing tags.
  • If there are no items between an opening and closing XAML tag, you can make it self-closing by placing the “/” before the “>” in the tag. These is called “self-closing”.
    • For example: “<RowDefinition Height=”Auto”/>”.

 

  • A common way to place objects on a XAML screen is to use a “grid”.
  • A grid has rows and columns. You can define their height and width as “Auto” (to make it the size of the controls inside of it), a number (to use a specific number of pixels), or “*” (to use all the remaining available space).
  • The top row is number “0”. The leftmost column is number “0”. As you move down (for rows), or to the right (for columns), the index increases by 1.
  • You place other controls on the screen by setting their row and column positions in the grid.

 

Source Code

MainWindow.xaml

 

Return to main page

Leave a Reply

Your email address will not be published. Required fields are marked *