示例#1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.MainView);

            _lvMonkeyList = FindViewById <MvxRecyclerView>(Resource.Id.monkeyList);
            var tvSelectedPosition   = FindViewById <TextView>(Resource.Id.tvSelectedPosition);
            var countUpButton        = FindViewById <Button>(Resource.Id.countUp);
            var countUpExecuteButton = FindViewById <Button>(Resource.Id.countUpExecuteButton);
            var gogoButton           = FindViewById <Button>(Resource.Id.gogoButton);
            var rbgSex = FindViewById <MvxRadioGroup>(Resource.Id.sexGroupe);


            _monkeyListAdapter    = new MonkeyRecyclerAdapter((IMvxAndroidBindingContext)this.BindingContext);
            _lvMonkeyList.Adapter = _monkeyListAdapter;


            rbgSex.CheckedChange += RbgSex_CheckedChange;

            var set = this.CreateBindingSet <MainView, Core.ViewModels.MainViewModel>();

            set.Bind(_lvMonkeyList).For(c => c.ItemsSource).To(vm => vm.MonkeyList);
            set.Bind(tvSelectedPosition).For(c => c.Text).To(vm => vm.SelectedIndex);
            set.Bind(countUpButton).For(c => c.BindClick()).To(vm => vm.CountUpCommand);
            set.Bind(countUpExecuteButton).For(c => c.BindClick()).To(vm => vm.CountUpExecuteCommand);
            set.Bind(gogoButton).For(c => c.BindClick()).To(vm => vm.GoGoCommand);
            set.Bind(rbgSex).For(c => c.ItemsSource).To(vm => vm.SexItems);
            set.Bind(rbgSex).For(c => c.BindSelectedItem()).To(vm => vm.SelectedSex);
            set.Bind(_lvMonkeyList).For(c => c.ItemClick).To(vm => vm.ItemSelected);

            set.Apply();
        }
示例#2
0
 public MonkeyViewHolder(View itemView, IMvxAndroidBindingContext context, MonkeyRecyclerAdapter adapter) : base(itemView, context)
 {
     _adapter        = adapter;
     itemView.Click += (sender, e) =>
     {
         _adapter.ItemSelected(AdapterPosition, itemView);
     };
 }