Exemple #1
0
        private void HandleAdapterViewItemChosen(AdapterView adapterView, int itemPosition)
        {
            if (itemPosition >= 0)
            {
                var adapter = adapterView.GetAdapter() as IDataBindableListAdapter;
                var binding = FindBindingForView(adapterView);
                if (adapter != null && binding != null)
                {
                    var value = adapter.GetItemAsObject(itemPosition);
                    switch (binding.Mode)
                    {
                    case BindingMode.Command:
                        var command = (RelayCommand)binding.ViewModelPropertyInfo.GetValue(viewModel);
                        command.Execute(value);
                        break;

                    case BindingMode.TwoWay:
                        binding.ViewModelPropertyInfo.SetValue(viewModel, value);
                        break;
                    }
                }
            }
        }