Button

Interactive button with ICommand binding, hover/focus colors, and keyboard support.

Overview

The Button control inherits from ButtonBase and supports the WPF ICommand pattern via the Command property. Buttons respond to Enter/Space keys when focused and mouse clicks. Visual states include focus and hover border colors.

<StackPanel Orientation="Horizontal">
    <Button Text="New" Width="12" Height="3" TabIndex="0"
            Command="{Binding NewCommand}" />
    <Button Text="Open" Width="12" Height="3" TabIndex="1"
            Command="{Binding OpenCommand}" />
    <Button Text="Delete" Width="12" Height="3" TabIndex="3"
            HoverColor="Red" Command="{Binding DeleteCommand}" />
</StackPanel>

ViewModel (C#)

Each button is wired to a RelayCommand that increments a click counter and records the last action.

public class ButtonsViewModel : ViewModelBase
{
    public int ClickCount { get; private set => SetProperty(ref field, value); }
    public string LastAction { get; set => SetProperty(ref field, value); } = "No button clicked yet";

    public ICommand NewCommand => field ??= new RelayCommand(() =>
    {
        ClickCount++;
        LastAction = $"New clicked (total: {ClickCount})";
    });
}

Key Concepts