Question

1. Binding Lists

I wonder how I could bind a ObservableCollection to a Radiogroup:

new Section(){
                new RootElement("Mandanten", new RadioGroup("mandanten", 2)) {
                    new Section(){
                        new RadioElement("Kupus", "mandanten"),
                        new RadioElement("Kajmak", "mandanten")
                    }
                }
            }

as you see here I'm creating 2 Items/Elements manually but I miss something like an "ItemsSource". If its not possible, what recommendation would you give me? To use witch Control (to bind Lists)?

2. CommandBinding

As I see theres no "button" in MonoTouch.Dialog. So I saw that we'll use "StringElement". I tried it, but after tapping on the "button" nothing happened:

new StringElement("Login").Bind(this, "SelectedCommand LoginCommand")

I'm not sure whats wrong, maybe I need to use here the new "variant", like that:

new EntryElement ("User", "Loginuser", ViewModel.User).Bind(target, v => v.Value, t => t.User),

But I'm not sure how to build that similiar code to bind a command for a particular "stringelement" (in that case - a button with the ontap event)..

Any help appreciated!

Was it helpful?

Solution

1. Binding lists

An example of binding dynamic ObservableCollection lists is in https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/ThirdView.cs - it uses some custom elements from https://github.com/slodge/MvvmCross-Tutorials/tree/master/DialogExamples/DialogExamples.Touch/BindableElements - which was based on the sample from https://github.com/asednev/MvvmCross.AlexeysExtensions

Because of the way Radio lists are internally implemented, I don't know if the same ObservableCollection binding approach would work for radio lists - someone would need to prototype and experiment to work this out. However, a simple fixed radio list is shown in https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/FirstView.cs

2. CommandBinding

See an example in: https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/FirstView.cs

                new Section("Action")
                    {
                        new StringElement("Second").Bind(bindings, element => element.SelectedCommand, vm => vm.GoSecondCommand),
                        new StringElement("Bindable Elements").Bind(bindings, element => element.SelectedCommand, vm => vm.BindableElementsCommand)  
                    },
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top