目前我在活动的OnCreate中执行以下操作,但它不是特别是MVVM,我想知道是否有更好的方法通过绑定?
var list = FindViewById<MvxListView>(Resource.Id.subslist); list.ItemClick = ((Myviewmodel)viewmodel).ItemSelectedCommand;
我找不到关于最佳方法的任何文档,所以任何帮助都会很棒.
解决方法
local:MvxBind="ItemClick ItemSelectedCommand"
您可以在以下示例中看到此操作:
> DailyDilbert – https://github.com/slodge/MvvmCross-Tutorials/blob/master/DailyDilbert/DailyDilbert.Droid/Resources/Layout/ListView.axml
> OldTutorial – https://github.com/slodge/MvvmCross-Tutorials/blob/master/Sample%20-%20Tutorial/OldTutorial/Tutorial.UI.Droid/Resources/Layout/Page_MainMenuView.axml
> N = 16 – Collect-A-Bull – 见http://youtu.be/1PC5Q30FyR4?t=26m10s和https://github.com/slodge/NPlus1DaysOfMvvmCross/blob/master/N-16-CollectABull-Part5/CollectABull.Droid/Resources/Layout/ListView.axml
不太常见(到目前为止),对于Android,您还可以绑定到MvxListView上的自定义绑定SelectedItem
此技术显示在MoreControls-https://github.com/slodge/MvvmCross-Tutorials/blob/master/MoreControls/MoreControls.Droid/Resources/Layout/FirstView.axml中的Spinner(MvxSpinner)上(此示例在N = 18视频期间实时构建 – 请参阅http://youtu.be/s1LhXdCTsn4?t=7m26s