Button
A standard button control that responds to click events.Properties
- Content: The button’s content (can be text or any visual element)
- Command: ICommand to execute when clicked
- CommandParameter: Parameter to pass to the command
- ClickMode: How button reacts to clicks -
Release(default) orPress - IsDefault: Whether button is triggered by Enter key (bool)
- IsCancel: Whether button is triggered by Escape key (bool)
- HotKey: Keyboard shortcut (KeyGesture)
- Flyout: Flyout menu to display when clicked
Events
- Click: Raised when the button is clicked
Example
- XAML
- C#
Click Modes
TheClickMode property determines when the Click event is raised:
TextBox
Represents a control for displaying or editing unformatted text.Properties
- Text: The text content (string)
- PlaceholderText: Placeholder text when empty (string)
- IsReadOnly: Whether text can be edited (bool)
- AcceptsReturn: Allow multiline input (bool)
- AcceptsTab: Allow tab character input (bool)
- MaxLength: Maximum character count (int)
- MaxLines/MinLines: Control height (int)
- TextAlignment: Text alignment -
Left,Center,Right - TextWrapping: Text wrapping mode -
NoWrap,Wrap,WrapWithOverflow - PasswordChar: Character for masking passwords (char)
- RevealPassword: Show/hide password (bool)
- CaretIndex: Position of text cursor (int)
- SelectionStart/SelectionEnd: Text selection range (int)
- IsUndoEnabled: Enable undo/redo (bool, default:
true) - UndoLimit: Maximum undo stack size (int)
Events
- TextChanged: Raised after text changes
- TextChanging: Raised when text starts to change
- CopyingToClipboard/CuttingToClipboard/PastingFromClipboard: Clipboard events
Example
- XAML
- C#
Text Selection and Editing
CheckBox
A check box control that can be checked, unchecked, or indeterminate.Properties
- IsChecked: Checked state -
true,false, ornullfor indeterminate (bool?) - Content: Label content
Events
- Checked: Raised when checked
- Unchecked: Raised when unchecked
- IsCheckedChanged: Raised when state changes
Example
- XAML
- C#
ComboBox
A drop-down list control.Properties
- Items: Collection of items
- SelectedItem: Currently selected item
- SelectedIndex: Index of selected item (int)
- IsDropDownOpen: Whether dropdown is open (bool)
- MaxDropDownHeight: Maximum height of dropdown (double, default: 200)
- PlaceholderText: Text shown when no item is selected
- IsEditable: Allow text input (bool)
Events
- SelectionChanged: Raised when selection changes
- DropDownOpened: Raised when dropdown opens
- DropDownClosed: Raised when dropdown closes
Example
- XAML
- C#
RadioButton
Represents a button that can be selected but not cleared by clicking.Slider
A control that lets users select from a range of values.ToggleButton
A button that can be toggled between checked and unchecked states.Best Practices
- Use appropriate input controls - Choose the right control for the data type
- Provide clear labels - Use TextBlock or Label to describe input fields
- Add validation - Validate input and show error messages
- Use data binding - Bind controls to view models for MVVM pattern
- Set placeholder text - Help users understand what to enter
- Handle events appropriately - Use commands for MVVM, events for code-behind