Use Mvvmcross Binding with MonoTouch.Dialog (Lists and Commands)

前端 未结 1 1046
悲&欢浪女
悲&欢浪女 2021-01-07 04:31

1. Binding Lists

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

new Section(){
                new RootElement(\"         


        
相关标签:
1条回答
  • 2021-01-07 04:52

    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)  
                        },
    
    0 讨论(0)
提交回复
热议问题