Cheesebaron
Cheesebaron

Reputation: 24460

MvvmCross: TwoWay bindings with MonoTouch.Dialog

Full source for this issue can be found here: https://github.com/Cheesebaron/MvvmCross.SettingsSample

My main concern lies in the SettingsView, where I try to bind some simple BooleanElements:

this.Root = new RootElement("Settings")
            {
                new Section("Test", string.Format("Choose to see your own location on the map.{0}Choose to allow shake gestures.{0}Choose whether you want to receive notifications.", Environment.NewLine))
                {
                    new BooleanElement("Show my location", ViewModel.ShowMyLocation).Bind(this, "{'Value':{'Path':'ShowMyLocation','Mode':'TwoWay'}}"),
                    new BooleanElement("Shake gestures", ViewModel.ShakeGestures).Bind(this, "{'Value':{'Path':'ShakeGestures','Mode':'TwoWay'}}"),
                    new BooleanElement("Notifications", ViewModel.Notifications).Bind(this, "{'Value':{'Path':'Notifications','Mode':'TwoWay'}}"),
                },
            };

My problem resides in that the bindings only seem to work one way, even though I explicitly specify that it is TwoWay. The two way bindings seem to work fine on WP7 and Android, so I know the view model is ok. But either I am missing some code for the two way bindings or something is wrong or missing in the framework.

This issue is also there if I try with other types of elements like CheckboxElement or StyledStringElement. Also my own made elements...

Upvotes: 1

Views: 1124

Answers (1)

Stuart
Stuart

Reputation: 66882

Following the comments above, this feels like this is a few separate problems:

Thanks for reporting these issues - and for following up with a test case. I will see if I can work out how to include some more formal test cases within the mvx repository.


As a future work item, I'd also quite like to formalise the Value and ValueChanged relationship - I think a general rule can be provided so that all Elements with Value and ValueChanged will support databinding - added as issue https://github.com/slodge/MvvmCross/issues/26.

Upvotes: 1

Related Questions