1.2.18 Using WPF Buttons

A Button Is a WPF User-Interface Control

A WPF Button gives the user a visible action they can activate.

A simple XAML button can look like:

XML / XAML
<Button
    Content="Show Roster"
    Click="ShowRoster_Click" />

The button participates in two layers:

Plain text
XAML → defines the control
C#   → handles the Click event

Content Controls What the User Sees

For:

XML / XAML
Content="Show Roster"

the button communicates its action to the user.

Use concise, meaningful wording.

The label should help the user predict what activating the button will do.

Click Connects the Control to C# Behavior

For:

XML / XAML
Click="ShowRoster_Click"

WPF uses the named event handler when the user activates the button.

The handler lives in the code-behind for the supplied window or control.

Preserve the Supplied Project Structure

When the course provides a WPF project:

Buttons Are Objects Too

A WPF Button is represented by an object at runtime.

You do not need to study the Button class hierarchy yet.

The useful idea is that user-interface controls are software objects with members and events.

Keep the Current Goal Small

At this stage, use buttons to connect a user action to a small C# event handler.

Complex interface architecture and advanced event behavior belong later.