Radiobuttons crash fix - #1795
Merged
Niels Laute (niels9001) merged 4 commits intoMar 8, 2025
Merged
Niels Laute (niels9001) merged 4 commits into
Niels Laute (niels9001) merged 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
PR Overview
This PR fixes a crash with RadioButtons on control sample pages by refactoring the event handling logic used to update control orientations and viewbox properties.
- Renamed event handlers from RadioButton_Checked to OrientationGroup_SelectionChanged for clarity.
- Updated the selection change logic to use pattern matching and Enum.TryParse for converting radio button tags.
- Added new event handlers for Stretch and StretchDirection control updates in the Viewbox sample.
Reviewed Changes
| File | Description |
|---|---|
| WinUIGallery/Samples/ControlPages/VariableSizedWrapGridPage.xaml.cs | Refactored the orientation update event handler using Enum.TryParse for Orientation. |
| WinUIGallery/Samples/ControlPages/StackPanelPage.xaml.cs | Refactored the orientation update event handler using Enum.TryParse for Orientation. |
| WinUIGallery/Samples/ControlPages/ViewboxPage.xaml.cs | Added event handlers for updating Stretch and StretchDirection using radio selections. |
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (4)
WinUIGallery/Samples/ControlPages/VariableSizedWrapGridPage.xaml.cs:24
- Consider using Enum.TryParse with the ignoreCase parameter (e.g. Enum.TryParse(selectedItem.Tag?.ToString(), true, out var orientation)) to ensure tag matching is case-insensitive.
if ((sender as RadioButtons)?.SelectedItem is not RadioButton selectedItem ||
WinUIGallery/Samples/ControlPages/StackPanelPage.xaml.cs:24
- Consider using Enum.TryParse with the ignoreCase parameter (e.g. Enum.TryParse(selectedItem.Tag?.ToString(), true, out var orientation)) to ensure tag matching is case-insensitive.
if ((sender as RadioButtons)?.SelectedItem is not RadioButton selectedItem ||
WinUIGallery/Samples/ControlPages/ViewboxPage.xaml.cs:74
- Consider using Enum.TryParse with ignoreCase set to true (e.g. Enum.TryParse(selectedItem.Tag?.ToString(), true, out var stretch)) to allow for case-insensitive tag matching.
if ((sender as RadioButtons)?.SelectedItem is not RadioButton selectedItem ||
WinUIGallery/Samples/ControlPages/ViewboxPage.xaml.cs:86
- Consider using Enum.TryParse with ignoreCase set to true (e.g. Enum.TryParse(selectedItem.Tag?.ToString(), true, out var stretchDirection)) to allow for case-insensitive tag matching.
if ((sender as RadioButtons)?.SelectedItem is not RadioButton selectedItem ||
Niels Laute (niels9001)
approved these changes
Mar 8, 2025
Niels Laute (niels9001)
enabled auto-merge (squash)
March 8, 2025 18:28
Collaborator
|
/azp run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses issues with
RadioButtons(microsoft/microsoft-ui-xaml#10347) on the control sample pages.Motivation and Context
How Has This Been Tested?
Ran the app and verified the changes. Also navigated through all the pages to check if other pages have the same issue.
Screenshots (if appropriate):
Types of changes