Press "Enter" to skip to content

Build a C#/WPF RPG

This is a new WPF/XAML game, based on the game from my Windows Form tutorial: Learn C# by Building a Simple RPG


For the latest version of the complete solution, visit:





Lesson 00.1: Overview



Lesson 01.1: Installing Visual Studio Community 2015 – Update 3

Lesson 01.2: Installing TortoiseSVN and VisualSVN



Lesson 02.1: Planning the Game



Lesson 03.1: Creating the Solution and Game Screen

Lesson 03.2: Creating and Using a Subversion Repository

Lesson 03.3: Creating the Player Class

Lesson 03.4: Creating the GameSession (ViewModel) Class

Lesson 03.5: Displaying the Player Object

Lesson 03.6: Update Player data with the PropertyChanged event

Lesson 04.1: Creating the Location class

Lesson 04.2: Creating the World

Lesson 04.3: Moving in the game world

Lesson 04.4: Improving the World – Inheritance and INotifyPropertyChanged

Lesson 04.5: Improving the World – Factory and Guard Clauses

Lesson 05.1: Creating the Game Item Factory

Lesson 05.2: Creating the Player Inventory

Lesson 06.1: Creating the Quest Factory

Lesson 06.2: Using Quests in the Game

Lesson 07.1: Creating Monsters

Lesson 07.2: Adding Monsters to Locations

Lesson 07.3: Sending Messages from the ViewModel to the View

Lesson 07.4: Monster Combat

Lesson 07.5: Monster and Combat Refactoring

Lesson 08.1: Completing Quests

Lesson 09.1: Creating Traders

Lesson 09.2: Adding the Trade Screen


Cleanup/refactoring, before adding more features

Lesson 10.1: Refactoring Base Class for Player, Monster, and Trader

Lesson 10.2: Grouping GameItems in Inventories

Lesson 10.3: Refactoring – Encapsulating LivingEntity Properties (Hit Points and Gold)

Lesson 10.4: Bug Fix – Removing multiple items from GroupedInventory

Lesson 10.5: Encapsulating Level and ExperiencePoints Properties

Lesson 10.6: Clean up property setters and PropertyChanged notifications


Create a base for automated tests

Lesson 11.1: Creating the Unit Test Project


New game features

Lesson 12.1: Making the GameItem class more flexible

Lesson 12.2: Creating the AttackWithWeapon command

Lesson 12.3: Making the Action class more flexible with an interface

Lesson 12.4: Letting the Monster use AttackWithWeapon

Lesson 12.5: Creating the first consumable GameItem

Lesson 12.6: Refactoring after adding Actions

Lesson 12.7: Creating recipes

Lesson 12.8: Crafting items with recipes

Lesson 13.1: Add keyboard input for actions, using delegates

Lesson 13.2: More keyboard actions (and fixes)


Load game world objects from XML files

Lesson 14.1: Moving game data to external files

Lesson 14.2: Creating extension methods

Lesson 14.3: Read World (Location) data from an XML file

Lesson 14.4: Read Monster data from an XML file

Lesson 14.5: Move Remaining Game Data to XML Files



Lesson 15.1: Bug Fixes, Unit Tests, and Tooltips

Lesson 15.2: Catch and log exceptions

Lesson 15.3: Building a “functional” inventory class

Lesson 15.4: Using GitHub to upload and download a solution


Better combat

Lesson 16.1: Adding centralized messaging

Lesson 16.2: Creating the Battle class

Lesson 16.3: Complex attack initiative and hit success logic


Continued lessons

Lesson 17.1: Saving and loading game state

Lesson 17.2: Reducing serialized data in save game file

Lesson 17.3: Add a menu to save and load the game state

Lesson 17.4: Automated test for saved game reader


Cleanup/bug fix

Lesson 99.1: Fix event subscriptions

Lesson 99.2: Replace random number library


Customizable Player attributes

Lesson 18.1: Making Configurable GameDetails

Lesson 18.2: New starting windows and configurable player races

Lesson 18.3: Player creation screen

Lesson 18.4: Adding Player Attributes to Living Entities

Lesson 18.5: Update game loading and saving


Upgrade and improvements

Lesson 19.1: Converting SOSCSRPG to .NET 5

Lesson 19.2: Identifying refactoring targets

Lesson 19.3: Move data and image files out of Engine project


  1. Dave Work
    Dave Work 2021-11-05

    Having pasted your entire file, I receive the following error in VS2019 and the window design does not appear:
    Severity Code Description Project File Line Suppression State
    Error Could not find file ‘C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ImageName’. WPFUI MainWindow.xaml 2

      SOSCSRPG 2021-11-05

      Hi Dave,

      I believe that is not a “real” error. Can you run the program, and does it look like it works?

      If the program runs correctly, that error is probably coming from Visual Studio trying to interpret the XAML page, which expects an instantiated Location object, with an ImageName value that points to a location (or monster) file. When you’re editing or compiling the program, and don’t have instantiated objects to bind to, Visual Studio shows that “error”.

      Please let me know if that is not the problem, or if my response is not clear.

      • Dave Work
        Dave Work 2021-11-10

        Hi Scott,

        Thanks for your response. The program runs ok.

Leave a Reply

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