WPF XAML Hello World

Leave a comment

Here is a simple example to get started with Windows Presentation Foundation (WPF) and Extensible Markup Language (XAML).

First, create a new Visual Studio project and select under Windows templates “WPF Application”:

You should see something like this in Visual Studio:

You will see a default window. Next, let’s add a button to the window. Open Toolbox and drag a Button across. Then, give the button a name:

Double click the button to go to the C# code. Add a line to display a message box:

Press F5 to run the code. Click Submit to see the message box:


Stop running. Go back to Visual Studio and note the XAML created:

Note the event on click which links to our C# code:

Clicking space in the attributes of the Button brings up several properties:




Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube


See more articles on: WPF

Leave a Reply

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