Instruction file imported from JDKoll1982/MTM_Waitlist (
.github/instructions/demos/BasicInput/RadioButtonDemo.instructions.md). Copyright stays with the author.
RadioButton
| Ecosystem | WinUI 3 |
| Category | Basic input |
| Level | Starter |
| API | Microsoft.UI.Xaml.Controls.RadioButton |
| Page | BasicInput/RadioButtonDemo (WinUI3LearningLab.Demos.BasicInput.RadioButtonDemo) |
| Kind | Live, interactive demo |
| Run it | WinUI3LearningLab.App.exe --demo radio-button |
What it teaches
One-of-many selection. Radio buttons sharing a GroupName (or the same parent) are mutually exclusive.
How the demo is built
The page is a UserControl at BasicInput/RadioButtonDemo.xaml, paired with RadioButtonDemo.xaml.cs. The shell hosts it inside Shell/DemoPage.xaml, which also shows both files verbatim — the snippet viewer reads the same source the app compiles, so what is displayed is always what runs.
Layout. Root UserControl with 12 element(s).
Named elements the code-behind touches: CsvOption, HeadersOption, StatusText.
Wired in XAML: OnFormatChecked(), OnOtherChecked().
Code-behind. Handlers OnFormatChecked(), OnOtherChecked(). 28 line(s), including the comments that record what the control does that the docs do not say.
Anything the demo cannot show is explained on the page rather than faked: the same rules the rest of the repo follows are in .github/instructions/winui3-api-rules.instructions.md.
MTM use case
MTM_Receiving_Application › Receiving › quick entry
The operator scans a part label, types a quantity and posts the receipt. Every action on that screen is a button, a drop-down or a toggle, and the disabled states are the guard that stops a receipt being posted before a dunnage type and quantity are both valid.
Schema this mirrors: receiving_history, receiving_package_types, dunnage_parts. Sample data for the page comes from src/WinUI3LearningLab.Core/LabData.cs — part numbers, bins, dunnage types and work orders, never Item 1 or John Doe.
Gotchas
- Grouping is by GroupName within a container — the same GroupName in a different panel is a different group unless the name matches.
- Use RadioButtons (plural) when the list is data-driven; it manages grouping and keyboard navigation for you.
- The first radio button in a group is selected by default unless you set IsChecked explicitly.
Try this
- Run
WinUI3LearningLab.App.exe --demo radio-button. The page showsRadioButtonDemo.xamlandRadioButtonDemo.xaml.csbeside the live demo, so the next edit can be made against something already running. - Change one value in the XAML and rebuild; the snippet viewer re-reads the file, so what is shown stays the code that compiled.
Documentation
Generated from DemoCatalog by --export-instructions. Do not edit by hand: change the descriptor in src/WinUI3LearningLab.Core/Catalog/BasicInput.cs or the demo source, then regenerate.
