Toggle Button Not Responding to Foreground Color when Unchecked

I don’t seem able to control the foreground color of a toggle switch control via datatrigger when it is in an off/unchecked state. I can change the color for on, and I can control the background for both a checked and unchecked state, but the switch itself always seems to revert to gray when “unchecked”.

Is this an issue with a Button control whose ButtonType is set to ToggleButton? Or is this an issue with the ToggleSwitch control?

The Button control should be allow you to change the Foreground when in the unchecked state. The ToggleSwitch however, will not. Its Foreground property only applies to the Checked appearance. Most of the ToggleSwitch visuals are provided by the platform so you will limited with what you can change. What you could do is use a ToggleButton instead & provide your own images.

1 Like

That one. That explains it. Thank you. (I’d click the solved button, but I can’t find it!)
New forum looks great!

I enabled the solved option on this category. You should see it now. You might have to click the ... button.

Thanks! I like it too. Complements to the folks at discourse.org

1 Like

What you could do is use a ToggleButton instead & provide your own images.

Is there an example of this somewhere?

Attached is an example showing how to create a custom toggle with your own images.
CustomToggle.hrp (6.0 KB)

It’s pretty much set up exactly the same as a standard ToggleSwitch. Has the exact same DataTriggers & EventTriggers. The difference is that it has 2 additional Property Triggers. These triggers change the Icon/Image when the Button’s IsChecked state changes.

1 Like

I’m still having trouble with this. The button reflects current status but doesn’t do anything when I press it. I have the same 4 triggers as a stock toggleswitch (two event triggers for checked and unchecked, two data triggers for locked and unlocked, and then I added two triggers you referenced above for IsChecked True and False with the two toggle images.

Should I have an IsClicked trigger somewhere?

Are you using the exact same Button from this example I shared with you?

Load that project on your Android device without changing anything in the file & test it.

Yes, your project with virtual switch works when I load it.

Nevermind, I got it to work. I had forgotten to change the button type to toggle. Thanks!

1 Like