Open jkhoel opened 1 year ago
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
Ran into this issue as well. Initially I was trying to use a switch. But when "off" the switch is not visible in dark mode, only the thumb is visible - so it just looks like a random circle on the screen (Windows, not tested on mobile). Changing background color for switch is not an option, it just makes a huge colored rectangle behind the switch - completely breaking the aesthetics. This switch issue has been mentioned here, here and here in addition to multiple posts on stackoverflow.
Decided to mimic the switch using icons and a CheckBox through ControlTemplate. Cannot. Thought I would just go back to the switch with a ControlTemplate. Cannot. Definitely did not want to explore the probable time consuming path of using shapes in a custom control to display a checked state in a pleasing manner.
Purpose of my post is:
Many hours spent on trying to implement something which should be trivial, much on research. Dark mode is advertised but seems to cause many issues with controls that have properties lockdown. Guess I'll have to go down the path with VisualStateManager and/or implement another pseudo-custom control.
It doesn't seem consistent for RadioButton to have ControlTemplate but not CheckBox. Is there any technical difficulty why it's not supported for CheckBox?
Description
I am unable to assign control templates to CheckBox elements. When looking at the code, it seems it has no
ControlTemplate
property and noOnControlTemplateChanged()
override when comparing to a RadioButton for example.I was expecting to be able to use the same principle to style or modify these components similarly, as they are both essentially buttons with different styling and slightly different behaviour.
Steps to Reproduce
CheckBox
inside XAMLLink to public reproduction project repository
No response
Version with bug
7.0.96
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
My workaround so far has been to completely ditch the MAUI CheckBox component completely, and implement my own.
The idea is to use custom visual states and then use these to toggle different SVGs (images) on and off.
MyCheckBox.xaml
MyCheckBox.xaml.cs
Relevant log output
No response