WPF Lesson 4.3 — Click Counter App

LessonsWPF Desktop → Lesson 4.3
WPF Desktop

Click Counter App

“Click. Click. Click. A big number goes up. Weirdly satisfying.”

⏱ About 15 minutes 🛠 Visual Studio Community ⭐ Lesson 3 of 3

What you will have

A WPF app with a giant click counter, a Reset button, an Undo button, and a high score that persists as long as the app is open.


Video Walkthrough

Watch the full lesson walkthrough.


Your prompt

Copy this. Paste it into your AI. Hit Enter.

📋 Your Prompt — Copy Everything Below
Create a WPF click counter application in C#. The app should show a large number in the centre of the window that starts at 0. A big “Click Me!” button increments the counter by 1 each click. A Reset button sets it back to 0. An Undo button reverses the last action. Track and display a high score — the highest number reached in the current session. Make the counter number large and bold.
✅ Copied! Now paste it into your AI.

What to do after

Follow these steps exactly.

1
Create a new WPF project
Visual Studio → WPF Application (C#) → name it ClickCounter → Create.
2
Replace both files
Replace MainWindow.xaml with the XAML. Replace MainWindow.xaml.cs with the C# code.
3
Press F5 and start clicking
Click the button. Watch the high score update. Try Reset then Undo.

🛠️ Didn’t work?

Remember — WPF has two files. Check XAML and CS are in the right places. Then:

1 Look at the error list at the bottom of Visual Studio
2 Copy the error message
3 Say: “This didn’t work. Here’s the error: [paste it]. Please fix it.”

Vibe Tweak

Make it count by 5 instead of 1.

Find the line that adds 1 to the counter. Change it to add 5 instead.

Find this
count += 1
Change to this
count += 5

Extra Credit

Want to go further?

📋 Extra Credit Prompt
Add milestone celebrations to the click counter. When the counter hits 10, 25, 50, and 100, change the background colour of the window and display a congratulations message for 2 seconds before returning to normal.
✅ Copied!

Reflection

WPF complete. Think about this.

“Three real Windows desktop apps. A greeter, a form with validation, and a counter with undo. These are the building blocks of every piece of desktop software you’ve ever used.”

WPF Complete! What’s next?
Ready to go physical? Try Arduino.
Make real things blink, respond, and sense the world around them.
Start Arduino →
Greg the Vibe Coder · gregthevibecoder.com 18 lessons · No account required