使用Mvvmcross与MonoTouch.Dialog(列表和命令)绑定 [英] Use Mvvmcross Binding with MonoTouch.Dialog (Lists and Commands)

查看:195
本文介绍了使用Mvvmcross与MonoTouch.Dialog(列表和命令)绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。绑定列表

我不知道我怎么能一个的ObservableCollection绑定到RadioGroup中:

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")
                    }
                }
            }

当你看到我在这里手动创建2个项目/元素,但我错过了什么样的的ItemsSource。
如果它不是可能的,什么会建议你给我吗?要使用女巫控制(绑定列表)?

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

在我孤单在MonoTouch.Dialog否按钮。所以,我看到我们将使用StringElement。
我试过,但窃听的按钮后,什么都没有发生:

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),

但我不知道如何构建similiar code为特定的stringelement(在这种情况下 - 与ONTA​​P事件的一个按钮)绑定命令。

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)..

任何帮助AP preciated!

Any help appreciated!

推荐答案

结合动态的ObservableCollection 列出一个例子是<一个href=\"https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/ThirdView.cs\" rel=\"nofollow\">https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/ThirdView.cs - 它使用从<一个有些自定义元素href=\"https://github.com/slodge/MvvmCross-Tutorials/tree/master/DialogExamples/DialogExamples.Touch/BindableElements\" rel=\"nofollow\">https://github.com/slodge/MvvmCross-Tutorials/tree/master/DialogExamples/DialogExamples.Touch/BindableElements - 这是基于对样本从 https://github.com/asednev/MvvmCross.AlexeysExtensions

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

由于的对讲机名单在内部实现,我不知道,如果在同一个的ObservableCollection 结合的方法将无线电名单的工作 - 有人需要原型和试验工作了这一点。然而,在<一个示出一个简单的固定的无线电列表href=\"https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/FirstView.cs\" rel=\"nofollow\">https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/FirstView.cs

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

见一个例子:<一href=\"https://github.com/slodge/MvvmCross-Tutorials/blob/master/DialogExamples/DialogExamples.Touch/Views/FirstView.cs\" rel=\"nofollow\">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)  
                    },

这篇关于使用Mvvmcross与MonoTouch.Dialog(列表和命令)绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆