Closed hayashida-katsutoshi closed 1 year ago
The bug also to happens when setting SelectedItem and SelectedItemIndex from code.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Still waiting for update.
Thanks for reporting this issue. I took a look and I did not run into issues binding to RadioButtons.SelectedIndex.
There are two issues with the code in the repro steps.
<RadioButtons SelectedIndex="{Binding SelectedTheme}" >
By default, Binding is OneWay. So interacting with the RadioButtons UI will not update the ViewModel. You can enable two way binding with:
<RadioButtons SelectedIndex="{Binding SelectedTheme, Mode=TwoWay}" >
The second issue is with this line:
App.Current.RequestedTheme = selectedTheme == 0 ? Microsoft.UI.Xaml.ApplicationTheme.Light : Microsoft.UI.Xaml.ApplicationTheme.Dark;
Application.RequestedTheme is only settable on app startup. See the Remarks section of the doc here: https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.requestedtheme?view=windows-app-sdk-1.4. So this code will not have the intended effect.
From my testing, RadioButtons.SelectedIndex appears to be working as expected in the general case.
Describe the bug
Binding to RadioButtons.SelectedIndex does not work in WinUI3 desktop.
Microsoft.WindowsAppSDK version 1.0.0.
Steps to reproduce the bug
MvvmGen generates concrete properties as below.
It looks similar with #4893, but it does not use ItemsSource.
Expected behavior
The sample code has a radio buttons. It is expected to call setter of SettingsViewModel.SelectedTheme.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 0.8: 0.8.0 (If you're seeing your issue in older previews of WinUI 3, please try this release)
Windows app type
Device form factor
Desktop
Windows version
May 2020 Update (19041)
Additional context
No response