Use Mvvmcross binding with MonoTouch.Dialog (lists and commands)
1. Binding lists
I wonder how I could bind the ObservableCollection to the Radiogroup:
new Section(){
new RootElement("Mandanten", new RadioGroup("mandanten", 2)) {
new Section(){
new RadioElement("Kupus", "mandanten"),
new RadioElement("Kajmak", "mandanten")
}
}
}
as you can see here I am creating 2 items / items manually but I am missing something like "ItemsSource". If this is not possible, what recommendation will you give me? Use witch control (to bind lists)?
2. CommandBinding
As I see theres no "button" in MonoTouch.Dialog. So I saw that we would be using "StringElement". I tried, but after clicking on "button" nothing happened:
new StringElement("Login").Bind(this, "SelectedCommand LoginCommand")
I'm not sure what happened, maybe I need to use a new "option" here, for example:
new EntryElement ("User", "Loginuser", ViewModel.User).Bind(target, v => v.Value, t => t.User),
But I'm not sure how to create this familiar code to bind a command to a specific "line item" (in this case, a button with an ontap event).
Any help is appreciated!
source to share
1. List of bindings
An example of dynamic list binding ObservableCollection
is at https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/ThirdView.cs - it uses some custom items from https://github.com/ slodge / MvvmCross-Tutorials / tree / master / DialogExamples / DialogExamples.Touch / BindableElements - which was based on the sample https://github.com/asednev/MvvmCross.AlexeysExtensions
Due to the fact that radio lists are implemented internally, I don't know if the same binding approach ObservableCollection
for radio lists would work - someone would need a prototype and experiment to fix this. However, a simple fixed list of radio stations is shown at https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/FirstView.cs
2. CommandBinding
See an example at: 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)
},
source to share