Hey guys,
I am trying to SetBinding to a switch in Code - behind (not XAML) but I have not been successful.
homePhoneSwitch.Toggled += (object sender, ToggledEventArgs e) => {
ViewModel.Settings.HomePhone = e.Value;
};
Doing the step above works fine but I have so many switches in my views and this is not an ideal solution.
I have attempted to use SetBinding like this:
homePhoneSwitch.SetBinding (Switch.IsToggledProperty, new Binding ("Settings.HomePhone"));
&& homePhoneSwitch.SetBinding (Switch.IsToggledProperty, new Binding ("ViewModel.Settings.HomePhone"));
&& homePhoneSwitch.SetBinding (Switch.IsToggledProperty, "Settings.HomePhone");
None of the above has worked for me. Is there something I am missing?
This is frustrating as on XAML its fairly straightforward but in the code-behind doesn't seem to work.
Any help is highly appreciated.