Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default ToggleSwitch behavior for initial IsChecked=null is weird #3276

Closed
lostmsu opened this issue Jun 21, 2018 · 3 comments · Fixed by #3756
Closed

Default ToggleSwitch behavior for initial IsChecked=null is weird #3276

lostmsu opened this issue Jun 21, 2018 · 3 comments · Fixed by #3756

Comments

@lostmsu
Copy link

lostmsu commented Jun 21, 2018

Describe the bug
ToggleSwitch.IsChecked property is of type bool?, hence can have 3 states, one being null.
The problem is - by default its visual behavior is unintuitive when the bound value is null:

  1. It shows no On or Off label
  2. Apart from 1., there's no visual indication, that it is null.
  3. There's no Unset label to set.
  4. Its looks Off by default (which might be OK default, but maybe should have separate property for the default).
  5. Important: upon clicking, it switches from null to Off, which is very confusing for the user, as they would expect it now become On.

To Reproduce
Steps to reproduce the behavior:

  1. Add ToggleSwitch
  2. Bind IsChecked to any bool? property with initial value null
  3. Observe there's no label at all, and switch looks Off
  4. Click on the switch

Expected behavior

  1. There's a special label for null, or Off is displayed, or whatever is set as default is displayed
  2. Upon click on the switch, it should turn to On if it looked Off before

Environment(please complete the following information):

  • MahApps.Metro version v1.6.4
  • OS: Win10 1803
  • Visual Studio 2017 15.7.4
  • .NET Framework 4.7.1
@b-mi
Copy link

b-mi commented Jan 14, 2019

Still not solved. Missing something like NullLabel="xxxx"

@timunie
Copy link
Collaborator

timunie commented Apr 4, 2019

I modified the template and the code behind to enable null-values. Unfortunatally i am not familar with changing the code here and make a pull-request. But if someone wants to implement this feature i can post the code here.

I also implemented a contentpresenter which you can use to have a custom content shown based on the state of the switch.

image

@timunie
Copy link
Collaborator

timunie commented Jun 6, 2019

I am currently working on a PR to implement a different behaviour there. But as this will be a breaking change i don't know if it will be implemented or not.

@punker76 There are currently two very similar controls. What do you think, can we drop one of these controls or make one based on the other to avoid dublicated code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants