maui
maui copied to clipboard
RadioButton application-level Style not working with ControlTemplate on iOS
Description
I'm using a ControlTemplate to define the look of my RadioButtons on a page. When I define the ControlTemplate and assign it as a Style to TargetType RadioButton in ContentPage.Resources the RadioButton behaves as expected on the ContentPage. If I move the ControlTemplate and the assignment of it as a Style to TargetType RadioButton in Styles.xaml as an Application level resource, the RadioButtons look as described in the ControlTemplate on iOS and Android but they do not respond to any clicks on iOS.
Steps to Reproduce
Build the app from the demo repository. You'll see the RadionButtons on MainPage are styled according to the ControlTemplate but they are unresponsive. If you move the ControlTemplate from Styles.xaml and put in as a ContentPage.Resource in MainPage.xaml, the RadioButtons respond as expected.
Link to public reproduction project repository
https://github.com/fischberg/RadioButtonControlTemplateBug
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
Tested on iOS 16.2 in emulator
Did you find any workaround?
Define the ControlTemplate as a page-level resource in ContentPage.Resources on every Page where I want to style RadioButton controls.
Relevant log output
No response
Reference stackoverflow discussion at: https://stackoverflow.com/questions/76156173/radiobutton-application-level-style-not-working-with-controltemplate-on-ios-in-m
Could you update the sample? https://github.com/fischberg/RadioButtonControlTemplateBug Looks empty.
Hi @fischberg. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Sorry folks. Not sure what happened. The repo is updated.
I run into the same issue and was struggling to figure out why.
I can confirm that it does indeed happen. When you try to style the button in Styles.xaml it's not working but when you move the ControlTemplate to the page where you want to use it, suddenly it works. I am lost for words...
@jsuarezruiz you can probably remove s/needs-info. Version 7.0.86
Actually, you don't even need to move the declaration of the ControlTemplate
to the page-level. Just don't set ControlTemplate
in the Style
but set it in the place where you use the button.
Fyi, if you use Setter.Value
and put your ControlTemplate
there, it doesn't work either.
Verified this on Visual Studio Enterprise 17.7.0 Preview 2.0. Repro on iOS 16.4, not repro on Windows 11 and Android 13.0-API33 with below Project: RadioButtonControlTemplateBug.zip
Can confirm this is still an issue in v8