-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implicitly grouped RadioButton
s are treated as in the same group
#1299
Comments
Seems by design? Unnamed RadioButtons are all in the same "group" and will find each other to make sure they stay mutually exclusive. Try setting GroupName on one of them to something non-default. |
They are not exclusive. You can check one RadioButton in each group after the initialization. |
If you just have two "ungrouped" RadioButtons in a page, they are exclusive. I think the bug is that at runtime if a flyout is open then changing one RadioButton doesn't affect the other because the closed flyout isn't in the tree and the RadioButton can't find its friend anymore. |
This behavior is not relevant to If But both can be checked manually by user input. <Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<StackPanel>
<RadioButton x:Name="RadioButton1" IsChecked="True" />
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="1">
<StackPanel>
<RadioButton x:Name="RadioButton2" IsChecked="True" />
</StackPanel>
</StackPanel>
</Grid>
</Page> using System.Diagnostics;
using Windows.UI.Xaml.Controls;
namespace App1
{
public sealed partial class MainPage : Page
{
public MainPage()
{
InitializeComponent();
Debug.WriteLine(RadioButton1.IsChecked); // False
Debug.WriteLine(RadioButton2.IsChecked); // True
RadioButton1.IsChecked = true;
Debug.WriteLine(RadioButton1.IsChecked); // True
Debug.WriteLine(RadioButton2.IsChecked); // False
// Click RadioButton2
RadioButton2.Checked += (sender, e) =>
{
Debug.WriteLine(RadioButton1.IsChecked); // True
Debug.WriteLine(RadioButton2.IsChecked); // True
};
}
}
}
|
In your later repro, if you wait until things have "settled", are both IsChecked properties still true? Sometimes these events fire before all the values are up to date (since we're calling the callback synchronously during state changes). Backing up a bit, what's the scenario you're trying to achieve? |
Right, there's clearly a bug here with the RadioButtons in flyouts. Looking at the code I suspect the bug may be that all unparented RadioButtons are treated as having the "same parent". And you may run into this case when setting IsChecked on elements during tree construction. I can leave this bug open as "needs winui 3" but it wouldn't help you now. But maybe this information would be useful for you to work around the bug. |
IsChecked="True"
attribute of implicitly grouped RadioButton
s takes effectRadioButton
s are treated as in the same group
duping to #2081 as the discussion there has more info |
This one is pretty bad. I ran across it trying to make the ColorPickerButton |
Describe the bug
Only one of implicitly grouped
RadioButton
s can be set toIsChecked
programmatically.Steps to reproduce the bug
Expected behavior
Actual behavior
Version Info
The text was updated successfully, but these errors were encountered: