Replies: 8 comments 16 replies
-
There already area styling options available for this, were you aware of those? Are those not sufficient? Why not? See: https://learn.microsoft.com/dotnet/maui/user-interface/controls/switch |
Beta Was this translation helpful? Give feedback.
-
Sorry, I wasn't really aware of these styling options via |
Beta Was this translation helpful? Give feedback.
-
Hi @jfversluis |
Beta Was this translation helpful? Give feedback.
-
Is there no way to control the color of the track when the switch is off? On some devices (e.g. a Pixel 6 Pro) it seems the default color has no visible contrast against a white background. The pixel emulators I've tried with seem to have a visible enough gray, but the physical device does not. |
Beta Was this translation helpful? Give feedback.
-
[REWRITE, 19th March 2025]. You can use BackgroundColor and Clip to setup the off color: <Switch BackgroundColor="Red" OnColor="Green" ThumbColor="Orange">
<Switch.Clip>
<RoundRectangleGeometry CornerRadius="10" Rect="0,10,40,20" />
</Switch.Clip>
</Switch> |
Beta Was this translation helpful? Give feedback.
-
I would like to see that, too. It is extremely annoying to have a switch with an invisible track and only a thumb. |
Beta Was this translation helpful? Give feedback.
-
Developers hate this one simple trick! Learn how: Screen.Recording.2025-05-09.at.13.13.45.movTask.Delay(5) to the rescue!
|
Beta Was this translation helpful? Give feedback.
-
it's absolutely insane that this isn't an option. We need an OffColor or a TrackColor property which we can then change via visualstates. |
Beta Was this translation helpful? Give feedback.
-
Description
Systems like Android often use a different Colors for the Slider and Thumb when they are toggled on or off like these:
Also on iOS it could be interesting to create such effects easily. It could be possible to create something with
OnPlatform
-Properties and then use certain properties in the ViewModel or where theSwitch
is bound to and then change states correspondingly in the Code-Behind.This, obviously is not so intuitive and also not so easily possible than having separate properties for:
So, I would propose to have certain properties for them and set them in
XAML
separately via these properties.Another proposal would be that the right Color is somehow calculated internally which on Android is often a bit lighter for the the Slider/Tint than the acutal ThumbOnColor:
So, when a certain Color is set (e.g. orange) the right lighter version of that orange is calculated internally so that it fits the standards on Android.
Anyway, defining Colors for values below would be nice to have:
Public API Changes
API Changes for the
Switch
Intended Use-Case
Use case is that developers can set the Colors for the following properties separately:
Beta Was this translation helpful? Give feedback.
All reactions