Today I am updating the Windows Store app in accordance with the redesign of the user interface. One change is replacing CheckBox
with ToggleSwitch
.
So, the code is updated with
<CheckBox IsChecked="{Binding BooleanProperty}" ...
to
<ToggleSwitch IsOn="{Binding BooleanProperty"} ... //does not update data source
Then I notice that when switching ToggleSwitch
not updated, I must add Mode=TwoWay
for it to work.
<Toggleswitch IsOn="{Binding BooleanProperty, Mode=TwoWay"} ... //update data source
From what I learned in WPF , I do not need to explicitly set the Mode=TwoWay
property of the CheckBox IsChecked, because it is TwoWay
by default.
In general, user-editable control properties, such as text fields and check boxes, have two-way bindings by default, while most other properties are bound to one-way relationships by default.
And I thought ToggleSwitch
is another CheckBox with better touch support, and it is only available in the Windows Store and Windows Phone apps.
Why is ToggleSwitch.IsOn
not used to bind TwoWay by default? Are there any other differences between CheckBox and ToggleSwitch?
source share