dotnet / dotnet/wpf

Radiobutton with GroupName sets value false second time window is opened

Open
#9,035 10 comments 1 reaction 1 assignee Claimed by @harshit7962 View on GitHub
:construction: work in progress Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

A wpf Window that has a set of RadioButton controls with GroupName set and IsChecked bound to an underlying property will set that property to `false` when a second instance of that window is opened after the first instance is closed.

If the GroupName attribute of the RadioButtons is not set, the property is not changed when opening a second window.

This is very similar to issue #2995 that was reported as fixed in October 2023 and possibly related to (same as?) issues #3751 and #7462 that were closed due to lack of repro.

### Reproduction Steps

A minimal repro project is available here: https://github.com/OpterJohan/RadiobuttonIssueRepro
Steps to reproduce:
* run the wpf app
* press the "Open details window" button
(A window named Details with 2 radio buttons opens. The radio button "Option 1" is set)
* close the "Details" window
* press the "Open details window" button again
(The Details-window opens again, but this time both the radio buttons "Option 1" and "Option 2" are not set)

If DetailsWindow.xaml is changed to that the radio buttons do not have GroupName, "Option 1" is set the second time the window is opened as well.

### Expected behavior

Bound property should be unaffected by old closed windows.
The behaviour should be the same regardless if a GroupName is given.

### Actual behavior

Bound property is set false.

### Regression?

Possible regression of #2995.

### Known Workarounds

Run GC.Collect before opening the window again seems to work in the minial repro project. Unclear if it would always work.

### Impact

Makes is more difficult to create a UI with multiple sets of radio buttons.

### Configuration

.net 8.0.2
Windows 11 10.0.22631.0, x64.

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.