You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
It shows no On or Off label
Apart from 1., there's no visual indication, that it is null.
There's no Unset label to set.
Its looks Off by default (which might be OK default, but maybe should have separate property for the default).
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:
Add ToggleSwitch
Bind IsChecked to any bool? property with initial value null
Observe there's no label at all, and switch looks Off
Click on the switch
Expected behavior
There's a special label for null, or Off is displayed, or whatever is set as default is displayed
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
The text was updated successfully, but these errors were encountered:
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.
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?
Describe the bug
ToggleSwitch.IsChecked
property is of typebool?
, hence can have 3 states, one beingnull
.The problem is - by default its visual behavior is unintuitive when the bound value is
null
:null
.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:
bool?
property with initial valuenull
Expected behavior
null
, or Off is displayed, or whatever is set as default is displayedEnvironment(please complete the following information):
The text was updated successfully, but these errors were encountered: